gpt4 book ai didi

java - 如何打印两个字符并且它们之间有空格?

转载 作者:行者123 更新时间:2023-12-01 19:35:39 25 4
gpt4 key购买 nike

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);
}
}

最佳答案

这样可以解决问题吗?

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

关于java - 如何打印两个字符并且它们之间有空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57696912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com