| Author |
Why this program is not printing any values???
|
Ivaturi Srinivas
Ranch Hand
Joined: Jun 03, 2003
Posts: 42
|
|
import java.util.*; public class SetExample { public static void main(String args[]) { List lst = new ArrayList(); lst.add("akp"); lst.add("me"); lst.add("ramki"); ListIterator iterator = lst.listIterator(lst.size()); while(iterator.hasNext()) { System.out.println((String)iterator.next()); } } }
|
 |
fei peng
Ranch Hand
Joined: Sep 15, 2003
Posts: 40
|
|
Hi,Srinivas I think the index of list is 0 based,the index list.size() means the bottom of list,so it contain no elements.
|
 |
Ivaturi Srinivas
Ranch Hand
Joined: Jun 03, 2003
Posts: 42
|
|
Yes You are right Thanks, I should not use lst.size() as parameter to print the Arraylist values. I removed that and able to print.
|
 |
 |
|
|
subject: Why this program is not printing any values???
|
|
|