7. Please complete the following codes (4 marks)
public class TestArray {
public static void main(String[] args) {
// create and initialize an array ‘myList’ with 4 elements. The values are the 4 elements are into 1.9,2.9,3.4 and 3.5
_______________________________
// Print all the array elements
for (double element: myList) {
System.out.println(element);
}
}
}
What is printed on execution of these methods?
public class TestArray {
public static void main(String[] args) {
// create and initialize an array ‘myList’ with 4 elements. The values are the 4
// elements are into 1.9,2.9,3.4 and 3.5
double[] myList = { 1.9, 2.9, 3.4, 3.5 };
// Print all the array elements
for (double element : myList) {
System.out.println(element);
}
}
}
Comments
Leave a comment