Page 1 of 1
Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 9:10 am
by javiut
States that the index must be between 0 and list size inclusive but this is not true.
- final List<String>myKidName = Arrays.asList("JOHN","STEPHEN","ORTIZ","RONDON");
System.out.println(myKidName.get(0)+" "+myKidName.get(myKidName.size()));
This is throwing
Code: Select all
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at java.util.Arrays$ArrayList.get(Arrays.java:3841)
Because the size is in range [0..3] and the size inclusive is not true must be inclusive and exclusive

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 9:37 am
by admin
The complete sentence that I see is, "Remember that for the get and the remove methods, the index must be between 0 and the
list’s size1 minus 1 (both inclusive)." (There is a typo size1)
This is correct. size minus 1 is indeed inclusive.
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 10:14 am
by javiut
i mean this line.
The index value must lie between 0 and list current size (Both inclusive) otherwise an Index just after the 13 for each paragraph.
The index always must be between 0 and list.size()-1 not only for get and remove methods but for all the methods which is a index is passed as parameters except the indexOf this is throwing exception as well you can see is a set method.
final List<String>myKidName = Arrays.asList("JOHN","STEPHEN","ORTIZ","RONDON");
System.out.println(myKidName.set(myKidName.size(),"LA ESTRELLA"));
But this is not throwing any.
Code: Select all
final List<String>myKidName = Arrays.asList("JOHN","STEPHEN","ORTIZ","RONDON");
System.out.println("myKidName = " + myKidName.indexOf(Integer.MAX_VALUE));
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 10:19 am
by admin
I am not able to find this line so may be it has already been fixed.
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 10:26 am
by javiut
Yes may be i have the october version

hehehe. did you as the author about the country name stuff?
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 10:29 am
by admin
Yes. We will add country for all of the readers mentioned on the ack page may be in the next version.
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 10:40 am
by javiut
awesome man thanks remember Venezuela is my country

which number version will be the next?
Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 333
Posted: Sun Mar 01, 2020 11:58 pm
by admin
I am unable to comment on the exact build number it will be there but it will be there.