SCJP – New Java 6 features

Main classes and methods

  • nextLong()
    • Scans the next token of the input as a long. This method will throw InputMismatchException if the next token cannot be translated into a valid long value as described below. If the translation is successful, the scanner advances past the input that matched.
  • hasNextLong
    • Returns true if the next token in this scanner's input can be interpreted as a long value in the default radix using the nextLong() method. The scanner does not advance past any input.
  • findInLine(Pattern pattern)

Console

  •  System.console()
  • readLine(String format, String args) - returns a string with the line read.
  • Invoking close() on the objects returned by the reader() and the writer() will not close the underlying stream of those objects.
  • methods doesn't throw checked exceptions
  • console.reader().close();  //close method throws IOException
  • Invoking close() on the objects returned by the reader() and the writer() will not close the underlying stream of those objects.
  • Scanner.nextLong returns the next long, but doesn't advance to the the input if it's not a long.

NavigableSet / NavigableMap

  • It's a new interface (extends SortedSet / sorted Map) for Java 6.

Tags:

Leave a Reply