To change the value of a specific element, refer to the index number:

Example

cars[0] = "Opel";
 



Example

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars[0] = "Opel";
System.out.println(cars[0]);
// Now outputs Opel instead of Volvo



Practice Excercise Practice now