Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i need details of how this thing works please Array Programming Write a static m

ID: 3863514 • Letter: I

Question

i need details of how this thing works please Array Programming Write a static method isAllEven that takes an array of integers as a parameter and that returns a boolean value indicating whether or not all of the values are even numbers (true for yes, false for no). For example, if a variable called list stores the following values: int[] list = {18, 0, 4, 204, 8, 4, 2, 18, 206, 1492, 42}; Then the call of isAllEven(list) should return true because each of these integers is an even number. If instead the list had stored these values: int[] list = {2, 4, 6, 8, 10, 208, 16, 7, 92, 14}; Then the call should return false because, although most of these values are even, the value 7 is an odd number.

Explanation / Answer

Program :

public class Sample1 {
/**
* * @param args the command line arguments
*/
static boolean isAllEven(int arr[]){
for(int i=0;i<arr.length;i++){
if(arr[i]%2==1){
return false;
}
}
return true;
}
public static void main(String[] args){
int[] list = {18, 0, 4, 204, 8, 4, 2, 18, 206, 1492, 42};
System.out.println(Arrays.toString(list)+" "+isAllEven(list));
int list2[] = {2, 4, 6, 8, 10, 208, 16, 7, 92, 14};
System.out.println(Arrays.toString(list2)+" "+isAllEven(list2));
}
}

OUTPUT :

[18, 0, 4, 204, 8, 4, 2, 18, 206, 1492, 42] true
[2, 4, 6, 8, 10, 208, 16, 7, 92, 14] false