【发布时间】:2016-11-09 14:44:53
【问题描述】:
下面是我的代码:
String str = "something";
char ch = 'e';
int noOfOcc = 1;
System.out.println("No of occurrences of '"+ch+"' in "+str+" is "+noOfOcc);
预期的输出应该如下:
No of occurrences of 'e' in "something" is 1
如何在双引号中打印 something?在这种情况下,我需要解决方案,我们在 System.out.println(); 中使用变量。我需要双引号中那个变量的值。
【问题讨论】:
-
使用反斜杠转义双引号
标签: java