Java StringBuffer 无法打印出撇号

Java StringBuffer cannot print out apostrophe

我会写一个片段,将两个字符串(具有特定元素)连接成一个。有人可以帮助我吗?

我的代码:

    import java.util.Scanner;

    public class Main {


        public static void main(String[] args) {
           Scanner sc = new Scanner(System.in);
           String first = sc.nextLine();

           String second = sc.nextLine();

          StringBuilder builder = new StringBuilder(" ");
           for(int i = 0; i < first.length(); i++){
               builder.append(first.charAt(i));
               builder.append(second.charAt(i));
           }
           String base = builder.toString();
           System.out.println(base);
        }

    }

汤姆,

问题是一串比另一串长。

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   String elso = sc.nextLine();

   String masodik = sc.nextLine();

  String longestString = elso; 
  String shortestString = masodik; 
  if (shortestString.length() > longestString.length()){
    shortestString = elso;
    longestString = masodik; 
  }
  StringBuilder builderem = new StringBuilder(" ");
   for(int i = 0; i < shortestString.length(); i++){
       builderem.append(shortestString.charAt(i));
       builderem.append(longestString.charAt(i));
   }
   for(int i = shortestString.length(); i < longestString.length(); i++){
       builderem.append(longestString.charAt(i));
   }
   String alapba = builderem.toString();
   System.out.println(alapba);
}
}

如果有效请告诉我!