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



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. PROGRAM TO FIND OUT SMALLER NU:-

cl

View Tutorial          By: ishaan gogna at 2012-05-09 19:00:49

2. haii...
I am Ahmed , i am in 3rd btech ,

View Tutorial          By: Ahmed at 2014-08-09 06:30:11

3. Thanks For This Explanatory Tutorial .
View Tutorial          By: Pralay at 2013-06-15 03:50:26

4. Unable to understand all the points, quiet confusi
View Tutorial          By: KB at 2015-04-15 10:11:14

5. Very good. very clear. thank you
View Tutorial          By: Andrei at 2012-12-16 04:29:36

6. thanx for providing good knowledge @ overriding
View Tutorial          By: Amol at 2011-05-05 02:28:43

7. int iNum2 = parseInt(“0xAâ
View Tutorial          By: Doug Whitehead at 2008-12-01 21:27:55

8. What is meant by source code portability?
View Tutorial          By: sathihs at 2012-11-02 11:16:57

9. org.replaceAll("is","was"); en
View Tutorial          By: nirosha at 2013-01-28 16:19:11

10. Nice explanation with appropriate example
View Tutorial          By: VL at 2009-04-09 06:17:37