fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. class Main {
  5.  
  6. static void solution(String first,String second) {
  7. //
  8. // write your logic here and print the desired output
  9. //
  10. String result="";
  11. int position=first.indexOf(second.charAt(0));
  12. if(position==-1)
  13. {
  14. result=first.substring(0,first.length()-1)+second.substring(1);
  15.  
  16. }
  17. else
  18. result=first.substring(0,position)+second;
  19. System.out.println(result);
  20. }
  21. // Following is the part of the program and is provided as an assistance to read the input.
  22. public static void main(String[] args) {
  23. Scanner in = new Scanner(System.in);
  24. String first = in.next();
  25. String second = in.next();
  26. solution(first, second);
  27. in.close();
  28. }
  29. }
Success #stdin #stdout 0.06s 4386816KB
stdin
smoke, fog
stdout
smokeog