-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringTest.java
More file actions
50 lines (34 loc) · 982 Bytes
/
StringTest.java
File metadata and controls
50 lines (34 loc) · 982 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
package String;
import org.junit.Test;
public class StringTest {
@Test
public void test3(){
String s1 = "Java";
String s2 = "hadoop";
String s3 = "Javahadoop";
String s4 = "Java" + "hadoop";
String s5 = s1 + "hadoop";
String s6 = s1 + s2;
System.out.println(s3 == s4);//true
System.out.println(s3 == s5);//false
System.out.println(s3 == s6);//false
String s7 = s4.intern();
System.out.println(s3 == s7);//true
}
@Test
public void test2(){
String s1 = "JAVAEE";
String s2 = "JAVAEE";
String s3 = new String("JAVAEE");
String s4 = new String("JAVAEE");
System.out.println(s1 == s2);//true
System.out.println(s1 == s3);//false
System.out.println(s3 == s4);//false
}
@Test
public void test1(){
String s1 = "abc";
String s2 = "abc";
System.out.println(s1 == s2);
}
}