我的程序中这一行出了什么问题?

时间:2014-11-30 04:02:14

标签: java arrays

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

这就是显示的内容。有什么建议吗?

1 个答案:

答案 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.");

+ - >用于连接字符串。