数组的大小无法修改。如果需要更大的数组,则必须实例化一个新数组。
更好的解决方案是使用
ArrayList可以根据需要增长的容器。
ArrayList.toArray( T[] a )如果你需要此形式的数组,该方法将为你提供数组。
List<String> where = new ArrayList<String>();where.add( ContactsContract.Contacts.HAS_PHONE_NUMBER+"=1" );where.add( ContactsContract.Contacts.IN_VISIBLE_GROUP+"=1" );
如果需要将其转换为简单数组…
String[] simpleArray = new String[ where.size() ];where.toArray( simpleArray );
但是,使用数组执行的大多数操作也可以使用此ArrayList进行:
// iterate over the arrayfor( String oneItem : where ) { ...}// get specific itemswhere.get( 1 );


