You should know about the following methods, not because they are in List but because they are in ArrayList, which is on the exam:
add
addAll
remove
removeAll
sublist
retainAll
get
contains
clear
size
HTH,
Paul.
About Question enthuware.ocajp.i.v7.2.1264 :
Moderator: admin
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Sat Jan 14, 2017 5:01 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
I am a bit confused on how a, c, b is printed.
I originally thought a, c, b, c would be printed because the subList() method would return c, due to the fact that subList's starting value is inclusive, and the first value is c, so it should include the String c.
Why is a, c, b printed but not a, c, b, c?
I originally thought a, c, b, c would be printed because the subList() method would return c, due to the fact that subList's starting value is inclusive, and the first value is c, so it should include the String c.
Why is a, c, b printed but not a, c, b, c?
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
If fromIndex and toIndex are equal (as is the case in this question), subList returns empty list. This is as per https://docs.oracle.com/javase/8/docs/a ... t-int-int-
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Tue Mar 06, 2018 9:54 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1264 :
As background information; here are some notes by Edsger Dijkstra on why ranges should be expressed as lower <= x < upper
https://www.cs.utexas.edu/users/EWD/tra ... WD831.html
https://www.cs.utexas.edu/users/EWD/tra ... WD831.html
Who is online
Users browsing this forum: No registered users and 46 guests