gpt4 book ai didi

java - 打印、阅读、运算符(operator)

转载 作者:行者123 更新时间:2023-11-30 09:12:04 25 4
gpt4 key购买 nike

我是 java 的新手,我应该得到如下输出:

输入您的名字:John

Hi, "John"
The name of this exercise is 'Modifying printing'.
Tabulator, line change and quotations have already been used in this exercise.
Backward slash (\) is also usable in printing.

练习结束

但我无法在 "" 中获取姓名部分,John。请任何人帮助我。我的代码如下所示:


import java.util.Scanner;
public class apples {
public static void main(String[] args) {
String s;
String m;
Scanner reader= new Scanner(System.in);
System.out.print("Type in your first name: ");
s= reader.nextLine();
m="Forward slash (\\) is also usable in printing.";
System.out.println();
System.out.println();
System.out.println("Hi, "+s);
System.out.println("\tThe name of this exercise is 'Modifying printing'.");
System.out.println("\tTabulator, line change and quotations have already been used in this exercise.");
System.out.println("\t"+m);
System.out.println();
System.out.println();
System.out.println("\t\t*** End of exercise ***");
}
}

最佳答案

 System.out.println("Hi, \"" + s + "\"");

其中\用于转义后面的 ".

在您喜欢的搜索引擎中搜索“java 中的转义字符”。

祝您开始使用 Java 愉快!

关于java - 打印、阅读、运算符(operator),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21805253/

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