• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Minor typo on page 124 (Java OCA 8 Programmer I Study Guide)

 
Cedric Georges
Greenhorn
Posts: 18
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 124, chapter "Sorting", there is a missing semicolon:


This line of code should be corrected as follow:

 
Cedric Georges
Greenhorn
Posts: 18
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the other hand, a new sorting method was introduced with Java SE8:


See https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html (bottom of page)
 
Cedric Georges
Greenhorn
Posts: 18
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On top of page 126, the following code is wrong:

"[]" are missing after "int":
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cedric Georges wrote:On page 124, chapter "Sorting", there is a missing semicolon:

This line of code should be corrected as follow:

You are correct!
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cedric Georges wrote:On top of page 126, the following code is wrong:

"[]" are missing after "int":

Spot-on!
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cedric Georges wrote:On the other hand, a new sorting method was introduced with Java SE8:

What about this method? Is it a typo? Or just a possible addition to the study guide?
 
Cedric Georges
Greenhorn
Posts: 18
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it isn't a typo. This could be an addition in the book, showing the possibility of using this new method.
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cedric Georges wrote:No, it isn't a typo. This could be an addition in the book, showing the possibility of using this new method.

True! But don't forget you are using a certification study guide. Its sole and only purpose is to prepare you for the exam. So it focuses mainly on the methods you need to know for the exam, not on every API method.

(PS. I'll have notified the authors about this thread so they can update the official errata overview)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've added the missing semi-colon and wrong data type to our errata list and credited you with the finding. Good eye!

Arrays.parallelSort() is intentionally not mentioned. The OCA exam only covers basic concepts and parallelization (or threading or concurrency) is not in that scope. The OCP exam does cover parallelization and the fork join framework (which parallelSort uses behind the scenes.) It doesn't cover this particular API though because it isn't in scope for the exam.

Fun note: Arrays.parallelSort() delegates to Arrays.sort() for small arrays.
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Fun note: Arrays.parallelSort() delegates to Arrays.sort() for small arrays.

And what's considered as a small array? 1000 elements? Or maybe 1 million? And does it make a difference if the array contains primitives or objects (which might have a complex graph and thus have a complex sorting algorithm)?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:And what's considered as a small array? 1000 elements? Or maybe 1 million? And does it make a difference if the array contains primitives or objects (which might have a complex graph and thus have a complex sorting algorithm)?

In OpenJDK, it is:
private static final int MIN_ARRAY_SORT_GRAN = 1 << 13;

Which is 8192. I have no idea why they picked this number.

And it doesn't vary by type.
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:private static final int MIN_ARRAY_SORT_GRAN = 1 << 13;

Which is 8192. I have no idea why they picked this number.

I wonder why they write something obscure like and not the really obviousWhile typing I probably know why 8192 = 2^13
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic