-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyString1.java
More file actions
48 lines (33 loc) · 921 Bytes
/
MyString1.java
File metadata and controls
48 lines (33 loc) · 921 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
45
46
47
48
import java.util.Scanner;
class MyString1{
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 String removeSpaces(String str){
String c = "";
for(int i = 0; i<str.length(); i++)
if(str.charAt(i) != ' ')
c += str.charAt(i);
return c;
}
public static void main(String[] args){
MyString1 l = new MyString1();
Scanner s = new Scanner(System.in);
String s1;
String s2;
s1 = s.nextLine();
s2 = l.removeSpaces(s1);
System.out.printf("%s",s2);
}
}