Mega Code Archive

 
Categories / Java Tutorial / Collections
 

To reference the components of an array

To reference the components of an array, use an index after the variable name. For example, the following snippet creates an array of four String objects and initializes its first member. public class MainClass {   public static void main(String[] args) {     String[] names = new String[4];     names[0] = "Hello World";   } }