Comment on Tutorial - How to use Iterator in Java By Fazal



Comment Added by : Steve

Comment Added at : 2012-01-18 15:58:31

Comment on Tutorial : How to use Iterator in Java By Fazal
I would like to know how to obtain the object that the Iterator is actually referencing. Not all ArrayLists will be storing Strings, and no matter what I do I cannot obtain the object being referenced by that iterator.

For example, if my ArrayList is storing MyClass objects I want to do something like this:

Iterator iter = theArrayList.iterator();
MyClass current = (MyClass)iter; // <--- What do I do here?


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Thanks it worked. Just remember to restart apache
View Tutorial          By: Raj at 2014-02-08 08:42:26

2. please sent the java code for course plan automati
View Tutorial          By: vijayakumar.r.r at 2009-08-27 01:39:22

3. thanq for this tutorial. It is very useful. But i'
View Tutorial          By: syahmi at 2010-03-06 02:55:05

4. After a great struggle I am able to successfully c
View Tutorial          By: raghu at 2012-01-04 15:10:07

5. Your explanation and example for toString() is gre
View Tutorial          By: Dinesh at 2012-10-19 08:29:13

6. I need complete steps for execution
Severa

View Tutorial          By: DASAn at 2011-08-10 10:10:36

7. it giving me error in following statment (using wi
View Tutorial          By: prathamesh at 2007-03-16 05:57:20

8. how i can used inheritence ?
View Tutorial          By: samee at 2008-02-16 12:54:27

9. dat is wat i want to jegay with you ,......dats ko
View Tutorial          By: dorji wangmo at 2011-12-27 05:38:35

10. Hi. When i click on Install certificate. It tells
View Tutorial          By: jaris at 2011-10-18 11:00:41