java - How do you change Vector to ArrayList? -
i developing application in java , since vector
obsolete required change using arraylist
.
this relevant code needs changed arraylist
:
this "house" class.
public vector<vector> getitems() { vector<vector> data = new vector<vector>(); (int = 0; < _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; }
this gui class:
private void updateview() { //gets rows , columns 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 , sets size + properties table1 = new jtable(rowdata, columnnames); table1.setpreferredscrollableviewportsize(new dimension(375, 325)); table1.setfillsviewportheight(true); //adds scrollpane container , sets component position center jscrollpane scrollpane = new jscrollpane(table1); centerpanel.add(scrollpane, borderlayout.center); }
i need entirely stop usage of vector , use arraylist instead. there simple way out? ways on how replace this?
vector<string> vector = new vector<string>(); // (... populate vector here...) arraylist<string> list = new arraylist<string>(vector);
this here java vector arraylist
Comments
Post a Comment