This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Sybex OCA Java 8 Study Guide:Chapter 3 mock explanation #23 Errata?

 
Ranch Hand
Posts: 271
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Line 4 creates a fixed size array of size 4.


Should be?

Line 4 creates a fixed size list of size 4.


 
Charles O'Leary
Ranch Hand
Posts: 271
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A Cool Trick with Varargs This topic isn't on the exam


Should be?

This topic is (subtle) on the exam

(please see original topic post)
 
Charles O'Leary
Ranch Hand
Posts: 271
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
page 137 ...This topic is (subtle) on the exam?
 
author & internet detective
Posts: 39392
763
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither of those are errata. For the array/list, it creates a list that is backed by an array. So both are correct . We could have made this clearer.

For the "A Cool Trick with Varargs" box, "isn't on the exam" is what we intended to say so it is correct. The Arrays.asList method is on the exam when you pass in an array. The exam doesn't ask about when you pass in elements and take advantage of varargs. And I do understand why that is. The reason they test Arrays.asList() is to test if you know about the relationship between the original array and the created List.

We mention it because:
1) We want to use the varargs version of the method in the book because it makes examples easier to read/write.
2) It is useful in real life code.

Thanks for asking though.
 
Charles O'Leary
Ranch Hand
Posts: 271
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,
It's your quite excellent book, so I'll give you the benefit of the doubt on both being correct since it is backed.    

I will not point out, no I won't do that, that in your own reply to this post, your words "it creates a list ..." and also I'm going to pivot into my next real question with this api doc:


@SafeVarargs
public static <T> List<T> asList(T... a)
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray(). The returned list is serializable and implements RandomAccess.
This method also provides a convenient way to create a fixed-size list initialized to contain several elements:

    List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");

Type Parameters:
T - the class of the objects in the array
Parameters:
a - the array by which the list will be backed
Returns:
a list view of the specified array



I'm just trying to get clear in my mind on the "This topic isn't on the exam" section.  Thus, my real questions:
There is only the above (un-overloaded, definitely not a real word, "version of the") varrargs method? "A Cool Trick with Varrargs" exemplifies "when you pass in elements and take advantage of varargs", along with Mock questions 23 and 25 (prompting my original "isn't" errata question, but I guess 23 and 25 are used to make it "easier to read/write")? Mock question 24 uses the array and is more like the combination of asList(varrags) - array that will really appear on the exam?  This is helpful to me because I'd like to get better timing and only focus on what needs to be focused on ... when I saw the options "the code doesn't compile" for 23 and 25 ... that didn't help my time much.

Thanks again Jeanne!

 
Jeanne Boyarsky
author & internet detective
Posts: 39392
763
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True. I meant they don't use the var-args capability and just pass in an array.

Yes, #23 and #25 are for our convenience and #24 is how you should expect to be tricked.
 
Charles O'Leary
Ranch Hand
Posts: 271
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get it now.  Thanks Jeanne.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!