pTutorial

New way to learn Programming

Java Array Example For Interview

In this section we will learn about java array example or you can say java array example for interview, java array interview question, java array machine test round question with explanation and output.

Array is the more power full concept in any programming language so that we will include a lot java array example following below.

Java Print Array Example

package pTutorial;

public class PrintArray {
    
    public static void main(String[] args) {
        
     int z[]=new int[5]; //declaration
     
     z[0]=152;
     
     z[1]=120; //initialization
     
     z[2]=12;
     
     z[3]=10;
     
     z[4]=258;//printing array  through loop
     
    for(int l=0;l<z.length;l++){
        
    System.out.println(z[l]);
    
    }
    System.out.println("Length of array = " + z.length);
}
 }


Output

152
120
12
10
258
Length of array = 5

Java Print Array Example

package pTutorial;

class PrintArray1{
    
    public static void main(String s[]){
        
        int z[]={07,38,17,9}; 
        
        for(int i=0;i<z.length;i++) 
            
        System.out.println(z[i]);  
    
      }
}  

Output

7
38
17
9

QUOTES OF THE DAY

Wonder is the first cause of philosophy.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER