How can I make Java print quotes, like “Hello”?

2019-01-02 23:31发布

How can I make Java print "Hello"?

When I type System.out.print("Hello"); the output will be Hello. What I am looking for is "Hello" with the quotes("").

13条回答
来,给爷笑一个
2楼-- · 2019-01-03 00:15

System.out.println("\"Hello\"");

查看更多
该账号已被封号
3楼-- · 2019-01-03 00:15

Take note, there are a few certain things to take note when running backslashes with specific characters.

System.out.println("Hello\\"); *edited
The output above will be :

Hello\

System.out.println(" Hello\" "); The output above will be:

Hello"

查看更多
Rolldiameter
4楼-- · 2019-01-03 00:18

This is probably the best answer you'll find:

while(True){
    System.out.println("\"Hello\"");
}
查看更多
我只想做你的唯一
5楼-- · 2019-01-03 00:22

You can do it using a unicode character also

System.out.print('\u0022' + "Hello" + '\u0022');
查看更多
Anthone
6楼-- · 2019-01-03 00:25

Use Escape sequence.

\"Hello\"

This will print "Hello".

查看更多
Anthone
7楼-- · 2019-01-03 00:28
System.out.print("\"Hello\"");

You are looking for Escape Sequences

See more List of Escape Sequences

查看更多
登录 后发表回答