-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyString.java
More file actions
44 lines (31 loc) · 822 Bytes
/
MyString.java
File metadata and controls
44 lines (31 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
37
38
39
40
41
42
43
44
import java.util.Scanner;
class MyString{
MyString(){
}
public static int whichFirst(String str1, String str2){
int n = 0;
str1 = str1.toLowerCase();
str2 = str2.toLowerCase();
if(str1.compareTo(str2)<0)
n = 1;
else if(str1.compareTo(str2)>0)
n = 2;
else
n = 0;
return n;
}
public static void main(String[] args){
MyString l = new MyString();
Scanner s = new Scanner(System.in);
String s1;
String s2;
s1 = s.nextLine();
s2 = s.nextLine();
int n = 0;
n = l.whichFirst(s1,s2);
if(n == 1)
System.out.printf("1 %s",s1);
else if(n == 2)
System.out.printf("2 %s",s2);
}
}