Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

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

 
Greenhorn
Posts: 18
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On top of page 126, the following code is wrong:

"[]" are missing after "int":
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
author & internet detective
Posts: 41763
885
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41763
885
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic