• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No ArrayIndexOutOfBoundsException in for loop, page 123 (Java OCA 8 Programmer I Study Guide)

 
Poyan Gerami
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chapter 3, page 123
Using an Array
for loop does not throw ArrayIndexOutOfBoundsException , condition in for loop shouled be '<=' ?

EDIT:

My fault you mean the for loop in page 124 throws ArrayIndexOutOfBoundsException, thats correct. Sometimes in the book you refers to code after the text and sometimes before, that should be more clear.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Poyan Gerami,

First of all, a warm welcome to CodeRanch!

Poyan Gerami wrote:My fault you mean the for loop in page 124 throws ArrayIndexOutOfBoundsException, thats correct. Sometimes in the book you refers to code after the text and sometimes before, that should be more clear.

As you already have discovered yourself, the question about the ArrayIndexOutOfBoundsException is about the statements on top of page 124. I think "why each of these" makes it pretty clear that this paragraph is not about the previous code snippet, because it suggests that there is more than 1 statement which throws an ArrayIndexOutOfBoundsException (and in the previous code snippet there is just one).

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic