Skip to content

Commit d716764

Browse files
committed
feat: Demonstrate basic array declaration, initialization, and default values in Java
🧠 Logic: - Declares primitive types (`int`, `String`) and introduces array syntax. - Initializes arrays with `new` and shows default values (`int` defaults to 0, `String` to null). - Explains stack vs. heap for array references and objects. - Example includes both individual variables and grouped data using arrays. Signed-off-by: Somesh diwan <[email protected]>
1 parent 1e5f0c1 commit d716764

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Section9ArrayAB/Array IMP/Main.java renamed to Section9ArrayAB/Array IMP/ModificationOfArray.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
public class Main {
1+
public class ModificationOfArray {
22

33
public static void main(String[] args) {
44
// Q: store a roll number
55
int a = 19;
66

77
// Q: store a person's name
8-
String name = "Kunal Kushwaha";
8+
String name = "Kunal";
99

1010
// Q: store 5 roll numbers
1111
int rno1 = 23;
@@ -19,8 +19,8 @@ public static void main(String[] args) {
1919
// // or directly
2020
// int[] rnos2 = {23, 12, 45, 32, 15};
2121

22-
int[] ros; // declaration of array. ros is getting defined in the stack
23-
ros = new int[5]; // initialisation: actually here object is being created in the memory (heap)
22+
int[] ros; // declaration of an array. ros is getting defined in the stack
23+
ros = new int[5]; // initialization: actually, here an object is being created in the memory (heap)
2424

2525
// System.out.println(ros[1]);
2626

0 commit comments

Comments
 (0)