Skip to content

Commit 986230f

Browse files
committed
string basic concept
1 parent e18efe2 commit 986230f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

String/Main.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package String;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
int[] arr = {2, 3, 5, 4, 19};
6+
int num = 10;
7+
String name = "Aamir Reza"; // strings are immutable
8+
// System.out.println(name);
9+
10+
String a = "Aamir";
11+
System.out.println(a);
12+
a = "Aamir";
13+
System.out.println(a); // here pooling concept is used therefore, both a will points towards same object in the heap memory in the pool.
14+
}
15+
}
16+
// if we decide to change the value of 'a' then a will points towards another object and Aamir will go to garbage collection.

0 commit comments

Comments
 (0)