my array is like as below:
unitList = new ArrayList<String>( Arrays.
asList(result.getJSONObject( position ).
getString( "units" ).replace("[", "").
replace("]", "").
split(",")));
I want to know if it have at least one element in this array, when I use this function:
unitList.size()
it return this:
06-30 02:04:51.453 18653-18653/search.bert.searchviewtest I/unitList.size: 1
06-30 02:04:51.453 18653-18653/search.bert.searchviewtest I/unitList: []
06-30 02:04:56.123 18653-18653/search.bert.searchviewtest I/unitList.size: 6
06-30 02:04:56.123 18653-18653/search.bert.searchviewtest I/unitList: ["1", "2", "3", "4", "5", "6"]
This is very strange, because [] do not have any element, but it return 1. If the list is ["1"], will it also return 1? How can I know if the list is empty or not?
supplement1:
My log code is as below:
Log.i("unitList.size", String.valueOf( ( unitList.size() ) ) );
Log.i("unitList",unitList.toString());