How to Access an Array in Java


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

Source Code

package com.beginner.examples;

public class AccessArray {
  public static void main(String[] args) {
    String[] strs = {"a", "b", "c", "d"}; // array
    strs[0] = "e";
    System.out.println(strs[0]);
  }
}

Output:

e

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments