Java程序以字符串形式显示双引号和单引号
以下是带单引号和双引号的字符串。
String str1 = "This is Jack's mobile"; String str2 = "\"This is it\"!";
上面,对于单引号,我们通常喜欢这样提及。
This is Jack's mobile
但是,对于双引号,请使用以下内容,并在开头和结尾添加斜杠。
String str2 = "\"This is it\"!";
以下是一个示例。
示例
public class Demo {
public static void main(String[] args) {
String str1 = "This is Jack's mobile";
String str2 = "\"This is it\"!";
System.out.println("Displaying Single Quote: "+str1);
System.out.println("Displaying Double Quotes: "+str2);
}
}输出结果
Displaying Single Quote: This is Jack's mobile Displaying Double Quotes: "This is it"!
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短