One Dimensional Array Initilization
One Dimensional Arrays

```class Main
{
public static void main(String args[])
{
int sum=0,x,n;
int marks[]={12,1,2,12,12,1,2,12,1,21,12};
n=marks.length;
for(x=0;x<n;x++)
{

sum=sum+marks[x];
}
System.out.println("Total marks are "+sum);
}
}

OUTPUT:

```

```
```

One Dimensional Array Declaration

```import java.util.*;
class Main
{
public static void main(String args[])
{
int sum=0,x,n;
int marks[]=new int[5];
n=marks.length;
Scanner s=new Scanner(System.in);
for(x=0;x<n;x++)
{
System.out.println("Enter subject "+(x+1)+" marks");
marks[x]=s.nextInt();
sum=sum+marks[x];
}
System.out.println("Total Marks Are "+sum);
}
}

OUTPUT:

```

One Dimensional Array Assignment

```class Main
{
public static void main(String args[])
{
int sum=0,x,n;
int marks[]=new int[5];
marks[0]=12;
marks[1]=12;
marks[2]=12;
marks[3]=12;
marks[4]=12;
n=marks.length;
for(x=0;x<n;x++)
{

sum=sum+marks[x];
}
System.out.println("Total Marks are "+sum);
}
}

OUTPUT:

```

Multi Dimensional Array Initilization
Multi Dimensional Arrays

```class Main
{
public static void main(String args[])
{
int sum=0,x,y;
int marks[][]={{1,1,1,1,1},{2,2,2,2,2},{3,3,3,3,3}};

for(x=0;x<3;x++)
{
for(y=0;y<5;y++)
{
sum=sum+marks[x][y];
}
System.out.println("Student "+(x+1)+" Marks are "+sum);
sum=0;
}
}
}

OUTPUT:

```

Multi Dimensional Array Declaration

```import java.util.*;
class Main
{
public static void main(String args[])
{
int sum=0,x,y;
int marks[][]=new int[3][5];
Scanner s=new Scanner(System.in);
for(x=0;x<3;x++)
{
for(y=0;y<5;y++)
{
System.out.println("Student "+(x+1)+" subject "+(y+1)+" Marks are");
marks[x][y]=s.nextInt();
sum=sum+marks[x][y];
}
System.out.println("Student "+(x+1)+" Marks are "+sum);
sum=0;
}
}
}

OUTPUT:

```

Multi Dimensional Array Assignmnent

```
class Main
{
public static void main(String args[])
{
int sum=0,x,y;
int marks[][]=new int[3][5];
marks[0][0]=12;
marks[0][1]=12;
marks[0][2]=12;
marks[0][3]=12;
marks[0][4]=12;
marks[1][0]=12;
marks[1][1]=12;
marks[1][2]=12;
marks[1][3]=12;
marks[1][4]=12;
marks[2][0]=12;
marks[2][1]=12;
marks[2][2]=12;
marks[2][3]=12;
marks[2][4]=12;
for(x=0;x<3;x++)
{
for(y=0;y<5;y++)
{

sum=sum+marks[x][y];
}
System.out.println("Student "+(x+1)+" Marks are "+sum);
sum=0;
}
}
}

OUTPUT:

```

Java Online Compiler