Question

20:51 Ο lt can be d with any objct of wny class that implesasts the Iterator ist n loop that is weitten by explicitly celing

20:51 t does ) An iner class is asubelas of ts oster lass without extende haxing to be ueed s ol) inner clu Thls is done becs

(question in green) What does it mean for an inner class object to be a reference of an outer class? what can you use an iterator on but not for each loop on?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Inner class means one class which is a member of another class. Inner classes has access to all members e.g. static and non-static variables and methods, including private of its outer class and may refer to them directly in the same way that other non-static members of the outer class do.

For example

class Outer {
  
class Inner {
public void display() {
System.out.println("This is inner class method");
}
}
}
public class Main {
public static void main(String[] args) {

   new Outer().new Inner().display();

}
}

For Iterator and For each loop

If you want to modify the Collection then use iterator because you can't do it with for each loop

And it will throw a ConcurrentModificationException

If you can modify or delete an item in collection by Iterator

Please let me know if you have any doubt or modify the answer, Thanks :)

Add a comment
Know the answer?
Add Answer to:
(question in green) What does it mean for an inner class object to be a reference...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT