Tue. May 28th, 2024

In multi dimension array of the arrays have unequal size then they are called Jagged array 

Example of Jagged array 

Creation of the above jagged array 

int[][] arr = new int[3][]; 

arr[0] = new int[3]; 

arr[1] = new int[2]; 

arr[2] = new int[4] 

Program

class ArrayDemo { 

   public static void main(String[] args) { 

int arr[][] = {{1.2.3}, {4,5,6}, {7,8,9}}; 

for(int i=0) i<arr.length; i++) { 

for(int j=0; j< arr[i].length; j++) { 

System.out.print(arr[i][j]+"") 

 } 

System.out.println(); 

} 

for(int[] x arr) { 

 for(int y: x) { 

 System.out.print (y+" "); 

} 

System.out.println(); 

    } 

  } 

} 

Program

class Student { 

public static void main(String[] args) { 

int[] marks= {91,95,100,89,79,99}; 

int total = 0; 

boolean result = true; 

System.out.println("student report card"); 

for(int i=0; i<marks.length; i++) { 

System.out.println("subject" + (i+1))+"marks: "+marks[i]) 

Total= total +marks[i]; 

if(marks[i] <35) 

result = false; 

} 

System.out.printin("total marks"+total); 

int avg = total/marks.length; 

System out println("average: "+avg); 

if(result) { 

if(avg >= 75) { 

System.out.println("Grade Distinction"); 

} 

else if(avg >= 60) { 

System out println("Grade First Class"); 

} 

else if(avg >= 50) { 

System.out.println("Grade Second Class"); 

} 

else ( System.out.println("Grade Third Class") 

 }  

} 

else {  

System.out.println("Welcome Again"); 

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *