forked from joharbatta/DataStructure-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths1.java
More file actions
36 lines (30 loc) · 822 Bytes
/
s1.java
File metadata and controls
36 lines (30 loc) · 822 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
public class s1{
public static void main(String args[])
{
//false answer as both as different obj as we use new memory make new object
// but if we use s1.equals(s2) its true
// also in " " here we have true false it also creates 2 objects " " creates string objects
String s1=new String("abc");
String s2=new String("abc");
if(s1==s2)
{
System.out.println("True");
}
else
{
System.out.println("False");
}
// // Here we got answer true both refers same obj
// String s1="abc";
// String s2="abc";
// if(s1==s2)
// {
// System.out.println("True");
// }
// else
// {
// System.out.println("False");
//
// }
}
}