-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringcompare.java
More file actions
50 lines (37 loc) · 1.09 KB
/
Stringcompare.java
File metadata and controls
50 lines (37 loc) · 1.09 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
//########################################## compare by equals() Method #############################################
public class Stringcompare
{
public static void main(String[] args)
{
String s1 = "juned";
String s2 = "juned";
String s3 = "javed";
String s4 = new String("juned");
System.out.println(s1.equals(s2));
System.out.println(s1.equals(s3));
System.out.println(s1.equals(s4));
}
}
// Case Ignore
public class Stringcompare
{
public static void main(String[] args)
{
String s1 = "juned";
String s2 = "Juned";
System.out.println(s1.equals(s2));
System.out.println(s1.equalsIgnoreCase(s2)); //Ignore Case
}
}
//################################### compare by == operator #############################################
public class Stringcompare
{
public static void main(String[] args)
{
String s1 = "juned";
String s2 = "juned";
String s3 = new String("juned");
System.out.println(s1==s2);
System.out.println(s1==s3);
}
}