class Solution {
public String solution(String str1, String str2) {
char[] char1 = str1.toCharArray();
char[] char2 = str2.toCharArray();
StringBuilder sb = new StringBuilder();
for (int i=0; i<char1.length; i++) {
sb.append(char1[i]).append(char2[i]);
}
return sb.toString();
}
}
Stringbuilder**
[charAt으로 하나하나 글자 떼오기]
class Solution {
public String solution(String str1, String str2) {
String answer = "";
for(int i = 0; i < str1.length(); i++){
answer+= str1.charAt(i);
answer+= str2.charAt(i);
}
return answer;
}
}
[Stringbuffer 사용]
import java.util.*;
class Solution {
public String solution(String str1, String str2) {
StringBuffer sb = new StringBuffer();
for (int i = 0;i < str1.length();i++)
sb.append(str1.charAt(i)).append(str2.charAt(i));
return sb.toString();
}
}