How can i add elements to the middle of pre existing 2D Arrays in java? -
i have array list declared such:
arraylist<arraylist<string>> info = new arraylist<arraylist<string>>;
i have filled inner array list strings parsed out of text file. later add together of array lists database.
after first parse through , add together info inner array list, want go in , add together additional info can't found in files parsing.
here code have tried not working:
void specialoperations(arraylist<arraylist<string>> data) { for(arraylist<string> sub: data){ string ip = sub.get(0); //system.out.println(sub.get(0)); sub.add(1,ip); } }
in example, first element in row ip address. trying add together same exact ip address sec element , force rest of info right. (there 2 of same ip addresses next each other). plan on padding ip address later want added first.
i know before send 2d arraylist "specialoperations" filled valid data, because can loop through , prints out right data, know not issue of empty data.
edit: have not used many other info types lists other array lists before. i've used hash maps , tree maps not much. if not right approach explain how utilize different one?
edit2: question auto linked says mine answered doesnt reply mine. know how add together middle. think there wrong how i'm implememnting 2d arraylist.
have @ this method of linkedlist:
inserts specified element @ specified position in list. shifts element @ position
i think need.
one more thing:
<arraylist<arraylist<string>> info = new arraylist<arraylist<string>>;
is bit strange. must
arraylist<arraylist<string> info = new arraylist<arraylist<string>>();
java arrays 2d
No comments:
Post a Comment