-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy path24 Array 1D 2D Jagged Array.txt
63 lines (51 loc) · 1.03 KB
/
24 Array 1D 2D Jagged Array.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Student
{
int rollno;
String name;
}
public class ArrayDemo
{
public static void main(String[] args)
{
/* ***1d Array***
// Student s1 = new Student();
// Student s2 = new Student();
// Student s3 = new Student();
// Student s4 = new Student();
//
// Student s[] = {s1,s2,s3,s4};
// int nums[] = new int[4];
int nums[] = {8,12,76,54};
// nums[0] = 8;
// nums[1] = 12;
// nums[2] = 76;
// nums[3] = 54;
// nums[4] = 77;
// nums[2] = 99;
// System.out.println(nums[2]);
// System.out.println(nums[4]);
for(int i=0;i<4;i++)
{
System.out.println(nums[i]);
}
*/
// 2D Array
int a[] = {1,2,3,4};
int b[] = {2,4,6,8};
int c[] = {5,6,7,8};
int d[][] = {
{1,2,3,4}, // Jagged Arrays
{2,4,8},
{5,6,7,8,9}
};
// System.out.println(d[0][1]);
for(int i=0;i<d.length;i++)
{
for(int j=0;j<d[i].length;j++)
{
System.out.print(" " + d[i][j]);
}
System.out.println();
}
}
}