java - continuously changing array size -


i have array of strings values in array changing continuously. there other way of managing array except removing items , changing index locations?

   public string[] deviceid=null;     deviceid=new string[devicecount]; 

in case devicecount changes new device comes. continuously need change array size , add or remove items

use arraylist in place of string[] .. , can cast arraylist string[] final output as

arraylist<string>  mstringlist= new arraylist<string>(); mstringlist.add("ann"); mstringlist.add("john"); string[] mstringarray = new string[mstringlist.size()]; mstringarray = mstringlist.toarray(mstringarray); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -