Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterator

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It compiles and execute perfectly without any output.

Why doesn't it throw any Exception ? neither iterator() nor hasNext() have any problem ?
 
Stephan van Hulst
Bartender
Pie
Posts: 6106
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes you think myList is null? What makes you think iterator is null?
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:What makes you think myList is null? What makes you think iterator is null?


Sorry that is not null but empty.I did never iterate empty collection so got confused.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic