// Station Data
private static final Object[][] dataFromSpace = new Object[][] {
{"Ram garh",45,110, "munshi jee"}
,{"Pluto",1000000,-50000,"Thor"}
,{"Jhumritaliya",66,110,null}
,{"Ram garh-Jr",45.9,110,null}
,{"planet-X",56E4+1,Double.NaN,null}
};
private List<S> stations=new ArrayList<S>();
testCore_JavA_SpaceRoutePlanner() throws RuntimeException {
for(int row = 0; row < dataFromSpace.length; row++) {
System.out.println(dataFromSpace[row][1]);
S s = (S)new Station(
(String)dataFromSpace[row][0],
(int)dataFromSpace[row][1],
(int)dataFromSpace[row][2],
(String)dataFromSpace[row][3]
);
stations.add(s);
}
}
在line(int)dataFromSpace [row] [1]和(int)dataFromSpace [row] [1]
中发生错误它给出了错误
Exception in thread "main" java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
答案 0 :(得分:1)
你可能会把它变成这样的双倍:
(double) dataFromSpace[row][2],