问题
I have an array of strings but the values in array is changing continuously changing. Is there any other way of managing the array except removing items and changing index locations?
public int[] deviceId=null;
deviceId=new String[deviceCount];
in my case deviceCount is changing as new device comes. so i continuously need to change array size and add or remove items
回答1:
Java offers a really handy mechanism known as the ArrayList. It's a dynamic array that you can use to do what you're describing.
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
来源:https://stackoverflow.com/questions/19216824/how-to-manage-continuous-changing-values-in-an-array-of-strings