java - ArrayList removes only content and not element -


i've written code similar this:

arraylist<string> somearraylist = new arraylist<string>(); .... .... inserts elements somearraylist .... .... int location = 4; somearraylist.remove(location); 

it has size of 5, when run through this, removes content @ position 4, size doesn't change, keeps being of 5 , when 4th element shown empty.

should else erase position 4 or what?

edit

logcat before removing:

04-14 15:03:41.790: w/system.err(22971): [1, 2, 3, 4] 04-14 15:03:41.790: w/system.err(22971): [1396850896.089319.jpg 04-14 15:03:41.790: w/system.err(22971): , 1396850896.47272.png 04-14 15:03:41.790: w/system.err(22971): , 1396850897.830785.jpg 04-14 15:03:41.790: w/system.err(22971): , 1396850895.729823.jpg 04-14 15:03:41.790: w/system.err(22971): ] 

logcat after doing somearraylist.remove(location);

04-14 15:03:41.790: w/system.err(22971): [1, 2, 3, 4] 04-14 15:03:41.790: w/system.err(22971): [1396850896.089319.jpg 04-14 15:03:41.790: w/system.err(22971): , 1396850896.47272.png 04-14 15:03:41.790: w/system.err(22971): , 1396850895.729823.jpg 04-14 15:03:41.790: w/system.err(22971): ] 

i this:

// ids      curfilename.movetofirst();     while(!curfilename.isafterlast()) {         ids.add(curfilename.getstring(curfilename.getcolumnindex("id")));         curfilename.movetonext();     }      // filenames      curfilename.movetofirst();     while(!curfilename.isafterlast()) {         filenames.add(curfilename.getstring(curfilename.getcolumnindex("filename")));         curfilename.movetonext();     } 

and after doing work:

filenames.remove(location); // location calculated when work being done 

try

somearraylist.trimtosize(); 

after removing element.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -