Login:  Password:    
forgot my password
sign up!
Search: 
 
  This post is part of:
    Online course(s):   
 Sun Certified Java Programmer 310-065

Sets, Maps and Comparable interface - Generics and Collections - Sun Certified Java Programmer 310-065 - Lesson 37 | Java courses

In this video we discuss few questions that deals with Sets, Maps, and the Comparable interface.

"
download the application please visit www.mrbool.com/player

Title: Sets, Maps and Comparable interface - Generics and Collections - Sun Certified Java Programmer 310-065 - Lesson 37

Duration:  16 minutes

Summary: This is the final video on Generics and Collections. In this final section, we discuss few questions that deals with Sets, Maps, and the Comparable interface. We start with the use of the subset method. We showed when both sets (the original and the subset) will be impacted when we add elements in the range and elements out of range. We also explained the difference between higherKey() and ceilingKey() and their impact on the output. We also went over TreeSets and how it needs to compare its elements in order to sort them. When the elements are basic types (integers, strings…), Java knows how to sort them. But when the elements are types that we create (Employee, Dog…), we need to implements the Comparable (or Comparator) interface to help the TreeSet in determining how we want out types to be sorted.

Methodology of the development of example: Good coding standard and simplified design to prepare for the Java programmer certification exam CX-310-065.

Technology Used: Java - Core Concepts.

Keywords: Class, Object, Integer, String, TreeSet, add(), subset(), pollFirst(), TreeMap, SortedMap, ArrayList, Comparable, Arrays, sort(), implements, binarySearch, Comparator, higherKey, ceilingKey.





Add a comment!
[Fechar]

Este post é fechado - você precisa ter acesso ao post para incluir um comentário.


Matthew Casperson
4/2/2012 2:9am
binarySearch and Comparators The explanation of why the binary search in question 16 returns negative 1 is a bit vague.

To use the function binarySearch(Object[] a, Object key) "the array must be sorted into ascending order according to the natural ordering of its elements (as by the sort(Object[]) method)". In question 16, the array has been sorted in reverse thanks to the Othello Comparator.

To search the array that has been sorted by a Comparator that does not use the natural ordering of the elements, you would need to use the binarySearch(T[] a, T key, Comparator<? super T> c) method.




Answer it
 
Mr.Bool Editor
4/19/2012 3:24pm
RE:   Mathew,
send your review to the author of the video, soon, will contact


Answer it
 
Ayad
4/20/2012 1:11am
RE:   Hi Matthew,
 
I really appreciate your detailed answers to the video questions (by the way, I did not write the questions; I just commented on them to give some direction). If I wrote the questions I would have written some of them differently.
Returning -1 when sorting is used, but to be on the safe side you better check for < 0 in that case).
And the sort with the comparator is used to sort any user defined classes (for example sorting Employees by last name, salary...).
Thanks again.
 
Ayad


Answer it
 



 
Help us to improve! Give us your feedback:
Give your note to the technical content
10 9 8 7 6 5 4 3 2 1
Give your note to the post's learning
10 9 8 7 6 5 4 3 2 1
Is this post helpful?
Yes No


Ayad Boudiab
Experience: A total of 10 years experience in developing applications using C++, Java, C#, ASP.NET, and SQL Server. In addition to 6 years experience in teaching programming courses at a local college. Degree: B.S. Computer Science Location: Atla...


Go to author's Space


Post stats:
Favorited:
 0

Post actions:
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 2,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 1,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,33
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits








mrbool.com
contact us   |   publish your post   |   buy credits

Copyright 2012 - all rights reserved to www.web-03.net