-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram2.java
More file actions
25 lines (18 loc) · 820 Bytes
/
program2.java
File metadata and controls
25 lines (18 loc) · 820 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
package StringClassCodes;
public class program2 {
public static void main(String[] args) {
String str1 = "Core2Web"; // String Constant Pool
String str2 = new String("Core2Web"); // Heap
char ch[]={'C','2','W'}; // Heap
String str3 = new String(ch);
System.out.println(System.identityHashCode(str1));
System.out.println(System.identityHashCode(str2));
System.out.println(System.identityHashCode(str3));
String str4 = "Core2Web";
String str5 = new String("Core2Web");
//Identity HashCode
System.out.println(System.identityHashCode(str4));
System.out.println(System.identityHashCode(str5));
System.out.println(System.identityHashCode(ch));
}
}