-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathJavaLangStringTest.java
More file actions
70 lines (56 loc) · 1.64 KB
/
JavaLangStringTest.java
File metadata and controls
70 lines (56 loc) · 1.64 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class JavaLangStringTest
{
public static void charAtIndex(String a, int b)
{
System.out.print(a.charAt(b));
}
public static void concat(String a, String b)
{
System.out.print(a.concat(b));
}
public static void testHashCode()
{
System.out.println("hello, world".hashCode());
System.out.println("HELLO, WORLD".toLowerCase().hashCode());
System.out.println((new String("hello, world")).hashCode());
}
public static void intern()
{
String te = "te";
String st = "st";
String test = te + st;
System.out.println(System.identityHashCode(test));
test.intern();
System.out.println(System.identityHashCode("test"));
}
public static void notInterned()
{
String te = "te";
String st = "st";
String test = te + st;
System.out.println(System.identityHashCode(test));
System.out.println(System.identityHashCode("test"));
}
public static void notInternedAfterLiteral()
{
String te = "te";
String st = "st";
String test = te + st;
System.out.println(System.identityHashCode(test));
System.out.println(System.identityHashCode("test"));
test.intern();
System.out.println(System.identityHashCode("test"));
}
public static void replace(String a, String b, String c)
{
System.out.print(a.replace(b, c));
}
public static void toLowerCase(String a)
{
System.out.print(a.toLowerCase());
}
public static void toUpperCase(String a)
{
System.out.print(a.toUpperCase());
}
}