-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringOutils.java
More file actions
68 lines (51 loc) · 1.21 KB
/
StringOutils.java
File metadata and controls
68 lines (51 loc) · 1.21 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.ArrayList;
public class StringOutils {
private String chars = "abcdefghijklmnopqrstuvwxyz";
public boolean palindrome(String word) {
int size = word.length();
int halfSize = word.length() / 2;
int i = 0;
int j = size-1;
while (i<halfSize && j>halfSize ) {
if (word.charAt(i) != word.charAt(j)) {
return false;
}else{
i++;
j--;
}
}
return true;
}
public String replaceEO(String word) {
String werd = "";
for (int i = 0; i<word.length();i++) {
if (word.charAt(i) != 'o') {
werd+=word.charAt(i);
}else{
werd+='e';
}
}
return werd;
}
public String concat(String a, String b) {
StringBuilder build = new StringBuilder(a);
build.append(b);
return build.toString();
}
public String[] explode(String a) {
return a.split(" ");
}
public String encrypt(String a, int key){
String result = "";
for (int i= 0; i<a.length();i++) {
char working=a.charAt(i);
int unicodeWork=Character.getNumericValue(working);
unicodeWork = unicodeWork + key;
char[] resultChar = Character.toChars(unicodeWork);
result += resultChar.toString();
}
return result;
}
// public String decrypt(){}
// public boolean isEqual(){}
}