-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDemo1.java
More file actions
52 lines (47 loc) · 1008 Bytes
/
Copy pathDemo1.java
File metadata and controls
52 lines (47 loc) · 1008 Bytes
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
public class Demo1 {
public static void main(String[] args) {
// Final Class (Java 1.0)
// it a group of characters (Char Array)
// Also Called as a DataType , But is a Class
// Immutable Class
// String use String Pool
String a ="Hello".intern(); // 1 or 0
String b = "Hello".intern();
String c = new String("Hello"); // 2 or 1
if(a==b){
System.out.println("Same Ref");
}
else
{
System.out.println("Not Same Ref");
}
//String x = new String();
//String y = new String("Hello");
a = "Bye";
if(a==b){
System.out.println("Same Ref");
}
else
{
System.out.println("Not Same Ref");
}
a ="Hello";
if(a==b){
System.out.println("Same Ref");
}
else
{
System.out.println("Not Same Ref");
}
String e = new String("Hi"); //2
String f = new String("Hi"); // 1
if(e==f){
System.out.println("Same Ref of e and f");
}
else
{
System.out.println("Not Same Ref of e and f");
}
// TODO Auto-generated method stub
}
}