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");