import java.util.Arrays;
class Scratch{
public static void main(String[] args){
int[] arr = new int[3];
System.out.println( Arrays.toString( arr ));
//prints [0, 0, 0]
}
}
int[] myArray = {0, 1, 2, 3};
System.out.println(Arrays.toString(myArray));
//prints [0, 1, 2, 3]
public class Array {
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5}; //Your array
for (int element: array) { //Advanced For Loop (For each)
System.out.println(element); //print each element of
//the array for each iteration
}
}
}
var array = [1,2,3]
for(var i = 0; i < array.length ; i++){
console.log(array[i])
}
Arrays.toString(array)
// Array of primitives:
int[] intArray = new int[] {1, 2, 3, 4, 5};
//output: [1, 2, 3, 4, 5]
// Array of object references:
String[] strArray = new String[] {"John", "Mary", "Bob"};
//output: [John, Mary, Bob]