class array{
public static void main(String[] args){
int arr[] = {1,2,3,4};
System.out.println("Before update" + arr[2]);
arr[2] = 9;//updating the value
System.out.println("After update" + arr[2]);
}
}
/*output:-
Before update3
After update9*/
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars[0]);
// Change elements in array
cars[0] = "Opel";
System.out.println(cars[0]);
// Length of array
System.out.println(cars.length);
// Loop through array
for (int i = 0; i < cars.length; i++) {
System.out.println(cars[i]);
}