我得到了一个复制和粘贴的代码,这是下面的代码,除了将双精度替换为int。我应该把它变成一个双精度的,所以我替换了所有的东西,但仍然收到一个可能的有损转换错误。你们知道哪里出问题了吗?
public class InitializingNumericgArray
{
public static void main(String [] args)
{
double [] doubleValues;
doubleValues = new double[10];
for(double n = 0; n <= 9; n+= 1)
{
System.out.println("index position " + n + " = "
+ doubleValues[n]);
}
}
}发布于 2020-10-25 17:31:20
错误包括:
数组的
doubleValuesn //被解释为doubleValues1.0,这是错误的
这是带有更正的代码:
public class InitializingNumericgArray
{
public static void main(String []args)
{
double []doubleValues;
doubleValues = new double[10];
for(int n = 0; n <= 9; n+= 1)
{
System.out.println("index position " + n + " = "
+ doubleValues[n]);
}
}
}https://stackoverflow.com/questions/40555403
复制相似问题