GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaArrays/EvenNumbers.md at main · AlexaJavaDev/JavaArrays

Expand file tree

/

EvenNumbers.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
27 lines (24 loc) · 625 Bytes
/

EvenNumbers.md

Copy path

File metadata and controls

27 lines (24 loc) · 625 Bytes
Raw
Copy raw file
Download raw file
Edit and raw actions

Что делает:
Выводит только чётные числа из массива.

Код:

public class EvenNumbers {
    public static void main(String[] args) {
        int[] num = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        System.out.println(printEven(num));
    }

    public static String printEven(int[] num) {
        String numbers = "";
        for (int i = 0; i < num.length; i++) {
            if (num[i] % 2 == 0) {
                numbers += num[i] + " ";
            }
        }
        return numbers;
    }
}

Пример вывода в консоли:

2 4 6 8 10
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.