[HD Pg 0, Sec. 9.2.4 - arrays-compare-and-arrays-mismatch-methods]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
DazedTurtle
Posts: 26
Joined: Wed Oct 02, 2019 1:42 pm
Contact:

[HD Pg 0, Sec. 9.2.4 - arrays-compare-and-arrays-mismatch-methods]

Post by DazedTurtle »

Just to clarify, there's no difference between alphabetical order and lexicographical order, correct? And the main thing to look out for is that it treats numbers the same way rather than putting them in order from smallest to largest (e.g. "1, 10, 100, 11, 2, 3" instead of "1, 2, 3, 10, 11, 100")?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 9.2.4 - arrays-compare-and-arrays-mismatch-methods]

Post by admin »

1. No, there is a difference between alphabetical and lexical (google it). Basically, alphabetical order is for alphabets only but lexical ordering is defined for any set of characters, numbers, etc. Lexicographical includes alphabetical comparison.
2. No, this has nothing to do with ordering of array elements. It is about comparing elements of two different arrays. If you are comparing two integer arrays, then it will compare integers at each position of those arrays. The comparison will be an integer comparison (which is a part of lexicographical comparison) i.e. 11 will be considered bigger than 2 and will therefore appear later than 2.

If you have two int arrays i1 = { 1, 2, 3, 4, 5 }; and i2 = { 1, 2, 3, 22 }; then i2 will be considered bigger than i1 because elements at 0, 1, 2 position are same but the element at the 3rd position is bigger in i2 ( 22 is more than 4 ).
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 61 guests