From my AP Computer Science A review book:
Consider this program segment. You may assume that the
wordListhas been declared asArrayList<String>.for(String s : wordList) if(s.length() < 4) System.out.println("SHORT WORD");"What is the maximum number of times SHORT WORD can be printed?"
The book says the answer is wordList.size(), but why wouldn't it be wordList.size()-1? Is the index of an ArrayList different from a regular array? My book says something about it automatically adding one to the index but I may have read that wrong.
java. ArrayList is zero-based (as are arrays). No difference there.