java - Is there a way to define the value of the index in an arraylist? -
java - Is there a way to define the value of the index in an arraylist? -
i had assignment due today ( late wont getting credit problem eating @ me) not figure out life of me. assignment goes followed: withoutten: homecoming version of given array 10's have been removed. remaining elements should shift left towards start of array needed, , empty spaces @ end of array should 0. {1, 10, 10, 2} yields {1, 2, 0, 0}. may modify , homecoming given array or create new array.
withoutten({1, 10, 10, 2}) --> {1, 2, 0, 0} withoutten({10, 2, 10}) --> {2, 0, 0} withoutten({1, 99, 10}) --> {1, 99, 0}
i have tried various things create programme work failed.
`
// arraylist defined integer class name of list
int i= 0; //loop for(i = 0; < list.size(); i++) { if( list.get(i) == 10) { list.remove(i); list.add(0); } } homecoming list;
` shows right result {1,2,0,0} one. can explain me if there way alter value of index if equals 10 , send of line 0?
i think not understand java syntax. not sense smug, code not think does. review java syntax knowledge , seek again. :-)
java arraylist integer
Comments
Post a Comment