我試圖創建浮點值的列表,但現在看來,這是不對的這樣: 編輯:如何創建列表<Float>?
public Supervisory() {
this.analogs = new ArrayList<Float>();
}
public void active() {
try {
for (ObjectIdentifier oi : ois) {
if (oi.getObjectType().intValue() == 2){
analogs.add(new Float(10));
}
}
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage());
}
}
我最後的代碼,它只是一個片段給我的問題的想法。
這個實現有什麼問題?
這是從你的代碼的確切的片段? –
哪裏是decleration,哪裏是初始化?什麼是錯誤? –
另外,爲什麼所有的答案都說要調用方法中的行?爲什麼不在構造函數中? –