如何打印两个字符以及它们之间的空格?

时间:2019-08-28 16:50:16

标签: java

package day1.examples;
import java.util.*;

public class AdvancedInput {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a,b;
        System.out.println("Enter Your First Name");
        a = sc.next().charAt(0);
        System.out.println("Enter Your Last Name");
        b = sc.next().charAt(0);
        System.out.println("Your Full name is:");
        System.out.println(a+b);
    }
}

1 个答案:

答案 0 :(得分:3)

这可以解决问题吗?

System.out.println("Your Full name is:");
System.out.println(a+" "+b);