How to Change an Array Element in Java


In this example we will show the method to change an array element in Java.

Source Code

package com.beginner.examples;

public class ChangeArray {
  public static void main(String[] args) {
    String[] scores = {"60", "80", "90"};
    scores[1] = "85"; // change an array element
    System.out.println(scores[1]);
  }
}

Output:

85
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments