forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForInExample.java
More file actions
47 lines (43 loc) · 808 Bytes
/
ForInExample.java
File metadata and controls
47 lines (43 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.examplehub.basics;
import java.util.ArrayList;
import java.util.List;
public class ForInExample {
public static void main(String[] args) {
int[] numbers = {5, 55, 555, 5555, 55555};
/*
* 5
* 55
* 555
* 5555
* 55555
*/
for (int number : numbers) {
System.out.println(number);
}
/*
* E
* H
*/
for (char ch : "ExampleHub".toCharArray()) {
if (Character.isUpperCase(ch)) {
System.out.println(ch);
}
}
/*
* Java
* Python
* C
*/
List<String> books =
new ArrayList<String>() {
{
add("Java");
add("Python");
add("C");
}
};
for (String book : books) {
System.out.println(book);
}
}
}