-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayListPractice.java
More file actions
51 lines (49 loc) · 1.35 KB
/
ArrayListPractice.java
File metadata and controls
51 lines (49 loc) · 1.35 KB
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
48
49
50
51
public class ArrayListPractice {
public static void main(String[] args){
int[] firstArray ={2,4,6,8,10};
int[] secondArray = {2,4,6,8,10};
boolean arraysEqual= true;
int i=0;
if(firstArray.length != secondArray.length){
arraysEqual=false;
}
while(arraysEqual && i<firstArray.length){
if(firstArray[i]!=secondArray[i]){
arraysEqual=false;
}
i++;
}
if(arraysEqual){
System.out.println("The arrays are equal.");
}else{
System.out.println("The arrays are not equal");
}
int[] numbers = new int[50];
getHighest(numbers);
getLowest(numbers);
}
public static void getHighest(int[] num){
for (int i=0; i<num.length; i++ ){
num[i] = i+1;
}
int highest = num[0];
for(int i =0; i<num.length; i++){
if(num[i]>highest){
highest = num[i];
}
}
System.out.println(highest);
}
public static void getLowest(int[] num){
for(int i=0; i<num.length; i++){
num[i] = i+1;
}
int lowest= num[0];
for(int i =0; i<num.length; i++){
if(num[i]<lowest){
lowest = num[i];
}
}
System.out.println(lowest);
}
}