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



Ask a Question

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. excellent notes
View Tutorial          By: jawahar at 2010-08-03 00:23:52

2. I'm coding a webservice and this is exactly what I
View Tutorial          By: Cristian at 2014-11-14 12:52:34

3. Hi for Java beginners this is the right place to s
View Tutorial          By: Anon at 2009-02-01 21:14:28

4. how to implement stack with using vector class
View Tutorial          By: anamika at 2015-08-25 18:58:29

5. that's what I've been looking for!!!!!!!!!!!!!!!!!
View Tutorial          By: bibi at 2014-12-28 20:43:56

6. Please send me application for sending message on
View Tutorial          By: jigar at 2011-12-21 11:53:48

7. we can write an abstract class without any abstrac
View Tutorial          By: keerthi at 2013-08-20 16:31:38

8. Very well explained Thanks.
View Tutorial          By: Anthony at 2012-12-12 00:20:39

9. Question: if clone is a protected method then why
View Tutorial          By: siva kiran at 2011-01-20 11:40:23

10. Thanks a ton!!! It was really very useful :)
View Tutorial          By: Ankit at 2015-05-11 12:30:41