Source Code : Initializing Array Values

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Initializing Array Values

Initializing Array Values
     
/*
This example creates a four element array with 1, 2, 3, 4 as the values. 
The length of the array, and the element at index 2, are printed out.
*/
public class TestArray {
  public static void main(String args[]) {
    int[] data = {
      1, 2, 3, 4
    };
        
    System.out.println("The length of the array is " + data.length);
    System.out.println("The element at index 2 is " + data[2]);
  }
}



           
         
    
    
    
    
  

Thank with us