Merging Two Strings
import java.util.Scanner;
class SolutionLe{
public static void main(String arg[]){
Scanner sc=new Scanner(System.in);
String word1=sc.next();
String word2=sc.next();
int i=0,j=0;
String s="";
while(i<word1.length() && j<word2.length()){
s=s+word1.charAt(i++);
s=s+word2.charAt(j++);
}
while(i<word1.length()){
s=s+word1.charAt(i++);
}
while(j<word2.length())
{
s=s+word2.charAt(j++);
}
System.out.println(s);
}
}
Comments
Post a Comment