Skip to content

Instantly share code, notes, and snippets.

@uggedal
Created October 22, 2008 20:45
Show Gist options
  • Save uggedal/18787 to your computer and use it in GitHub Desktop.
Save uggedal/18787 to your computer and use it in GitHub Desktop.
Differences Between SCJP 5 and 6
================================
From the Objectives
-------------------
"Given a scenario involving ... interacting with the user ... develop
the correct solution using the following classes from Java.io:
... Console."
"Write code that uses the NavigableSet and NavigableMap interfaces."
From the Sun Certification FAQ
------------------------------
* Questions concerning System.gc() have been removed.
* Coverage of the java.io.Console class has been added.
* Coverage of navigable collections has been added.
* Several of the previous objectives have been strengthened
(so you can expect more questions and more detailed questions
on them). These strengthened objectives include:
- exception handling,
- collection classes and collection interfaces,
- assertions,
- threads,
- and flow control.
From the Study Guide
--------------------
* Note about the exclusion of System.gc() in SCJP 6.
* java.io.Console section.
* Section on NavigableSet and NavigableMap.
* No further coverage of the "strengthened objectives".
Lets Digest the Good News First
-------------------------------
"The topic of using System.gc() have been removed from the exam. The
garbage collector has evolved to such an advanced state that it's
recommended that you never invoke System.gc() in your code -- leave
it to the JVM."
java.io.Console
---------------
* New to Java 6.
* If you run Java from the console you typically have access to
a console object.
* It is possible to run Java programs in an environment where
you don't have access to such an object.
* You get a reference to such an object with:
System.console()
* This invocation could return null!
* Input:
readLine() # Returns a string
readPassword() # Returns a character array
* If password input were stored as strings one could not be sure
that it could be completely removed from memory.
Console Example:
----------------
import java.io.Console;
import myapi;
Console c = System.console();
char[] pw;
pw = c.readPassword("%s", "Password: ");
String name = "";
name = c.readLine("%s", "Username: ");
myapi.createUserAccount(name, pw);
c.format("Dear %s, we have created your account\n", name);
Navigating TreeSets and TreeMaps
--------------------------------
* java.util.NavigableSet and java.util.NavigableMap are new
interfaces in Java 6.
* For the purpose of the exam we are interested in how
TreeSet and TreeMap are implementing these.
* We need to know:
- TreeSet.ceiling(e) # lowest element >= e
- TreeMap.ceilingKey(key) # lowest key >= key
- TreeSet.higher(e) # lowest element > e
- TreeMap.higherKey(key) # lowest key > key
- TreeSet.floor(e) # highest element <= e
- TreeMap.floorKey(key) # highest key <= key
- TreeSet.lower(e) # highest element < e
- TreeMap.lowerKey(key) # highest key < key
Other "Navigation" Methods
--------------------------
* We need to know:
- TreeSet.pollFirst() # returns and removes first entry
- TreeMap.pollFirstEntry() # returns and removes first k/v pair
- TreeSet.pollLast() # returns and removes last entry
- TreeMap.pollLastEntry() # returns and removes last k/v pair
- TreeSet.descendingSet() # returns a NavigableSet in reverse
- TreeSet.descendingMap() # returns a NavigableMap in reverse
Backed Collections
------------------
* We need to know:
- .headSet(e, b*) # subset ending at element e (exlusive)
- .headMap(e, b*) # submap ending at key k (exlusive)
- .tailSet(e, b*) # subset ending at element e (inclusive)
- .tailMap(e, b*) # submap ending at key k (inclusive)
- .subSet(s, b*, e, b*) # subset starting at element s and
ending just before element e
- .subMap(s, b*, e, b*) # submap starting at key s and ending
just before key e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment