TreeSet -

1) pollFirst() - removes the first entry

2) pollLast() - removes the last entry.

3) descendingSet() - in reverse order

TreeMap - 

1) pollFirstEntry() - removes the first entry

2) pollLastEntry() - removes the last entry.

3) descendingMap() - in reverseOrder.

9) PriorityQueue - 

- offers three new methods - peek, poll, offer

- offer is to add elements.

- poll() removes the highest priority value from the queue.

- peek() displays the highest priority value without removing from the queue.

10) Generics -

- To ensure safe collection. From java 5 they have introduced Generics.

- Running mix of generic and non-generic code may result in run-time errors.

- Non - generic get methods should return Objects .

- Type safety is only done at compiler and not at runtime.

- UnBoxing occurs only when the object is Long or Integer. Unboxing cannot convert general Object to an primitive int.

11) Polymorphism and Generics.

- Polymorphism dont apply for generics. 

- Generic Methods wont accept polymorphic arguments.

- we can add instances of subtypes into the collection even though the collection is supertype specific. (same as array).

- In generic methods we cannot use add() method. the method declaration will look something like this 

(List<? extends Animal> animal) - but cannnot add any thing

(List <? super Dog> animal) - accept all the parameters that are dog and super to dog.

(List <?> animal) - takes any generic list but you are not supposed to add any thing.

12) Creating Generic classes.

- class name <T>

write the code.

13) Generic methods

* public <T> void methodName() - declare type variable first. 

*A null cannot be autoboxed to 0.

* for subtree headset (x,true) means include x

* for subtree .tailset(x,true) means exclude x

ALL about SCJP = SCJP 1.6, mock, certification, scjp 1.5 , scjp questions, scjp books, scjp hand written notes, scjp dumps, scjp trainings, scjp video tutorials, scjp simulators etc.