在Java中使用System.out.printf命令出现问题
在Java中使用System.out.printf命令出现问题
我刚接触编程,所以提前道歉。我正在运行一个程序,但在Java中的System.out.printf
方法上遇到问题。我知道程序中的其他部分都正常工作(已经测试过了)。然而这个方法似乎不起作用。
错误信息如下:
Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
at java.util.Formatter$FormatSpecifier.print(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at Advisor_Score.main(Advisor_Score.java:17)
我的代码是:
import java.lang.Math; public class Advisor_Score { public static void main(String[] args){ double l[] = {101,1,1,1}; double k[] = {102,2,2,4}; double m[] = {103,5,5,5,5,5,5,5}; double All_users[][]={l,k,m}; double sum[]=new double [All_users.length]; double [] raw_advisor=new double [All_users.length]; double []advisor_score= new double [All_users.length]; for (int i=0;i
不太确定为什么它不起作用。