Java でアプリケーションを開発していますが、Vector
廃止されたため、これを using に変更する必要がありArrayList
ます。
これは、次のように変更する必要がある関連コードですArrayList
。
これが「ハウス」クラスです。
public Vector<Vector> getItems() {
Vector<Vector> data = new Vector<Vector>();
for (int i = 0; i < _itemList.size(); i++) {
Vector<String> row = new Vector<String>();
row.add(_itemList.get(i).getDecription());
row.add(String.valueOf(_itemList.get(i).getprice()));
data.add(row);
}
return data;
}
これは GUI クラスです。
private void updateView() {
//Gets Rows and Columns from the House.class
Vector<Vector> rowData = _listener.getHouse().getItems();
Vector<String> columnNames = new Vector<String>();
columnNames.add("Product Name");
columnNames.add("Product Price(€)");
//Creates Shopping Cart and sets size + properties
table1 = new JTable(rowData, columnNames);
table1.setPreferredScrollableViewportSize(new Dimension(375, 325));
table1.setFillsViewportHeight(true);
//Adds ScrollPane to the container and sets the component position to center
JScrollPane scrollPane = new JScrollPane(table1);
centerPanel.add(scrollPane, BorderLayout.CENTER);
}
VECTOR の使用を完全に停止し、代わりに ArrayList を使用する必要があります。簡単な方法はありますか?これを置き換える方法はありますか?