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. why we use the java in networking and What are the
View Tutorial          By: ali mohammed at 2015-10-11 23:03:40

2. Nice tutorial, I got how it's done, but the differ
View Tutorial          By: FriendlyNoob at 2015-07-20 17:27:08

3. very good tutorial..
View Tutorial          By: shobhit at 2010-05-04 12:17:41

4. public class Overload2 {


View Tutorial          By: ITMIT at 2011-06-05 19:16:46

5. Thanks for the tutorial,

I have a q

View Tutorial          By: rajendra at 2013-04-29 15:37:28

6. thanku very much. it is a good examples for abstr
View Tutorial          By: rajesh at 2010-12-17 10:57:42

7. Nice one. I havn't thought of this before.
View Tutorial          By: Aniket Sawant at 2013-04-09 05:40:58

8. hello sir i want to know how to run this pogram as
View Tutorial          By: Pranjay at 2009-01-07 03:33:45

9. Hi

Anybody plz send me the sms send

View Tutorial          By: Venky at 2008-11-19 08:33:22

10. it is possible to write any synchronisation progra
View Tutorial          By: shashi kant mishra at 2013-10-14 02:54:25