-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathStringPool.java
More file actions
19 lines (18 loc) · 529 Bytes
/
Copy pathStringPool.java
File metadata and controls
19 lines (18 loc) · 529 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Same "Java" object is shared by both references.
*
* @author L.Gobinath
*/
public class StringPool {
public static void main(String[] args) {
String x = "Java";
String y = "Java";
System.out.println(x == y); //true
System.out.println(x.toLowerCase()); // java
System.out.println(x); // Java
System.out.println(y); // Java
x = x.toLowerCase(); // Update the reference
System.out.println(x); // java
System.out.println(y); // Java
}
}