-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathString5.java
More file actions
36 lines (27 loc) · 926 Bytes
/
Copy pathString5.java
File metadata and controls
36 lines (27 loc) · 926 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
package main.java.StringHandling;
/**
* Created by neeraj.bhatnagar on 1/10/2017.
*/
public class String5 {
public static void main(String[] args) {
/**
* CompareTo function will compare two strings. If
* s1== s2 : 0
* s1 > s2 : positive value
* s1 < s2 : negative value
*/
String s1 = "Neeraj";
String s2 = "neeraj";
String s3 = "Bhatnagar";
String s4 = "Kumar";
String s5 = "Kumar";
System.out.println(s1.compareTo(s2));
System.out.println(s1.compareToIgnoreCase(s2));
System.out.println(s1.compareTo(s3));
System.out.println(s3.compareTo(s1));
System.out.println("-------------------------------------------------------------");
System.out.println(s4.compareTo(s5));
System.out.println(s1.compareTo(s5));
System.out.println(s4.compareTo(s1));
}
}