-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequal_fun.java
More file actions
40 lines (35 loc) · 937 Bytes
/
Copy pathequal_fun.java
File metadata and controls
40 lines (35 loc) · 937 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
public class equal_fun
{
public static void main(String[] args)
{
String str1="tony";
String str2="tony";
String str3= new String("tony");
if(str1==str2)
{
System.out.println("strings are equal");
}
else
{
System.out.println("strings are not equal");
}
//here not equal is print because by using new keyword new memory is allocate thats why we use equal function
if(str1==str3)
{
System.out.println("strings are equal");
}
else
{
System.out.println("strings are not equal");
}
// equal function
if(str2.equals(str3))
{
System.out.println("strings are equal");
}
else
{
System.out.println("strings are not equal");
}
}
}