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:28

There are two easy methods:

  1. Use backslash \ before double quotes.
  2. Use two single quotes instead of double quotes like '' instead of "

For example:

System.out.println("\"Hello\"");                       
System.out.println("''Hello''"); 
查看更多
登录 后发表回答