System.out.println(numArray[i] "which is" (100*numArray[i]/theSum) " % of the sum.");
我的程序中的所有内容似乎都很好,除了最后一行。我尝试了所有我能想到的东西,它仍然显示错误。
- The type of the expression must be an array type but it resolved
to int
- Syntax error on token ""which is"", [ expected
- Syntax error on token "" % of the sum."", ] expected
- Syntax error on token "" % of the sum"", ] expected
- Syntax error on token "", which is"", [ expected
这就是显示的内容。有什么建议吗?
答案 0 :(得分:1)
更改此
System.out.println(numArray[i] "which is" (100*numArray[i]/theSum) " % of the sum.");
到
System.out.println(numArray[i] + "which is" + (100*numArray[i]/theSum) + " % of the sum.");
+
- >用于连接字符串。