Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • 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: 10763
148
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!