-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringnew.java
More file actions
47 lines (41 loc) · 884 Bytes
/
Stringnew.java
File metadata and controls
47 lines (41 loc) · 884 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
public class Stringnew {
public static void main(String args[])
{
String str_a = "Hello";
String str_b = "Hello";
String str1 = new String("Hello");
String str2 = new String("Hello");
if(str_a==str_b)//== checks address location
{
System.out.println("if(str_a==str_b)");
}
else
{
System.out.println("else (str_a==str_b)");
}
if(str_a.equals(str_b))//equals() checks content
{
System.out.println("if str_a.equals(str_b)");
}
else
{
System.out.println("else str_a.equals(str_b)");
}
if(str1==str2)//== checks address location
{
System.out.println("if str1.equals(str2)");
}
else
{
System.out.println("else (str_a==str_b)");
}
if(str1.equals(str2))//equals() checks content
{
System.out.println("if str1.equals(str2)");
}
else
{
System.out.println("else str1.equals(str2)");
}
}
}