-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrimWhiteSpaces.java
More file actions
40 lines (33 loc) · 1002 Bytes
/
TrimWhiteSpaces.java
File metadata and controls
40 lines (33 loc) · 1002 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
package algorithmExamples;
/*
* @author Muhammed Fatih ÖZDİL
* @since Wed Mar 03 2021
*
*/
import java.util.Scanner;
public class TrimWhiteSpaces {
public static String Trim(String str) {
String newString = "";
for (int i = 0; i < str.length(); i++) {
char a = str.charAt(i);
String b = String.valueOf(a);
if (b.equals(" ")) {
if (i + 1 != str.length()) {
char c = str.charAt(i + 1);
newString += String.valueOf(c).toUpperCase();
i++;
}
} else {
newString += b;
}
}
return newString;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter your password");
String password = scanner.nextLine();
scanner.close();
System.out.println(Trim(password));
}
}