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. I have loaded allthe 5 java files.But how to imple
View Tutorial          By: ashish at 2007-03-08 20:33:11

2. Good explanation, Thanks.
View Tutorial          By: bram at 2011-05-06 03:37:54

3. in this matter i get also this exception :

View Tutorial          By: oded at 2008-09-28 05:41:35

4. no output as well, i'm getting portlist and portId
View Tutorial          By: raul at 2015-10-09 20:05:02

5. /* getword: get next word or character from input
View Tutorial          By: Vinod S at 2011-12-02 07:53:52

6. Hey thanks for your tutorial. But i'm getting an e
View Tutorial          By: acc at 2013-07-25 14:30:50

7. very simple explanation......
easily unders

View Tutorial          By: saurabh at 2009-04-17 16:02:30

8. How to send to multiple mobiles at a time
View Tutorial          By: rakesh at 2010-04-30 10:33:51

9. java to learn is very easy .................but do
View Tutorial          By: yunus khan at 2012-12-06 17:28:41

10. ASNWERING: what's the purpose of indexOf('t',10)
View Tutorial          By: Kyle at 2012-03-22 09:17:04