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
| class Solution {
public String solution(String s) {
String answer = "";
String[] split = s.split(" "); //글자 자르기
String[] replace = new String[split.length];
for (int i = 0; i < replace.length; i++) {
replace[i]="";
}
for (int i = 0; i < split.length; i++) {
for (int j = 0; j < split[i].length(); j++) {
String word = split[i].substring(j, j+1);
if(j%2==1){
replace[i]+=word;
}else{
word = word.toUpperCase();
replace[i]+=word;
}
}
}
for (int i = 0; i < replace.length; i++) {
answer+=replace[i];
if(i!=replace.length-1){
answer+=" ";
}
}
return answer;
}
}
|