以下是带单引号和双引号的字符串。Stringstr1="ThisisJack'smobile";
Stringstr2="\"Thisisit\"!";
上面,对于单引号,我们通常喜欢这样提及。ThisisJack'smobile
但是,对于双引号,请使用以下内容,并在开头和结尾添加斜杠。Stringstr2="\"Thisisit\"!";
以下是一个示例。
示例publicclassDemo{
publicstaticvoidmain(String[]args){
Stringstr1="ThisisJack'smobile";
Stringstr2="\"Thisisit\"!";
System.out.println("DisplayingSingleQuote:"+str1);
System.out.println("DisplayingDoubleQuotes:"+str2);
}
}
输出结果DisplayingSingleQuote:ThisisJack'smobile
DisplayingDoubleQuotes:"Thisisit"!