-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayEx.java
More file actions
35 lines (32 loc) · 922 Bytes
/
ArrayEx.java
File metadata and controls
35 lines (32 loc) · 922 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
import java.util.Scanner;
import java.util.Arrays;
public class ArrayEx {
public static void main(String[] args) {
int[] iArr;
iArr = new int[5];
iArr[0] = 20;
iArr[1] = 40;
iArr[2] = 100;
iArr[3] = 32;
iArr[4] = 22;
for (int i =0 ; i < 5; i++){
System.out.println(iArr[i]);
}
int[] evens = new int[]{2, 4, 6, 8,10, 12};
for (int i:evens){
System.out.println(i);
}
int[] tableof5 = {5, 10, 15, 20, 25, 30};
int[] iArr1 = new int[5];
System.arraycopy(iArr, 0, iArr1, 0, 5);
for (int i: iArr1){
System.out.println(i);
}
String[] fruits = new String[]{"apple","banna","cashew","grapes","pear"};
for (String f : fruits){
if (f.contains("ap")){
System.out.println(f);
}
}
}
}