Array Declaration
1)declaration
Memory allocation
public class declaration1 {
public static void main(String[] args) {
// DECLARATION
int[] marks;
// MEMORY ALLOCATION
marks = new int[5];
marks[0] = 37;
marks[1] = 23;
marks[2] = 44;
marks[3] = 63;
marks[4] = 43;
System.out.println(marks[4]);
}
}
2)Declaration +Memory Allocation
public class d2 {
public static void main(String[] args) {
int[] marks = new int[5]; //DECLARATION + MEMORY ALLOCATION
marks[0] = 37;
marks[1] = 23;
marks[2] = 44;
marks[3] = 63;
marks[4] = 43;
System.out.println(marks[4]);
}
}
3)Declaration + Initialization
public class d3 {
public static void main(String[] args) {
// Declaration+ Initialization
int[] marks = { 100, 78, 45, 33, 77 };
System.out.println(marks[4]);
}
}
Comments
Post a Comment