hi guys i want to know what is the problem in this progam
public static void main(String as[]) { Collection c = new ArrayList();//line 1 c.add("one"); c.add("two"); c.add("three"); c.add(null); c.add(null); System.out.println(" size "+c.size()); Iterator it=c.iterator(); while(it.hasNext()) { it.hasNext(); it.remove(); }
System.out.println(" size "+c.size());
}
when i run this progam iam getting following exception Exception in thread "main" java.lang.IllegalStateException at java.util.AbstractList$Itr.remove(Unknown Source) at src.com.cc.main(cc.java:23)
also i changed line 1 to ArrayList c = new ArrayList(); but still iam getting this error
looking for your replies
Charles Lyons
Author
Ranch Hand
Joined: Mar 27, 2003
Posts: 836
posted
0
should be
and also
hi guys i want to know what is the problem in this progam
should be
Hi guys I want to know please what is the problem in this program
[ October 14, 2008: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )