Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
14 Cards in this Set
- Front
- Back
Switch statement
|
We can use a String object
|
|
Integral types (byte, short, int, long)
|
Can be expressed using the binary number system
|
|
Binary literals
|
Can be used in a switch statement (just like any integral type)
|
|
Numerical literals with underscore
|
-We can use any number of underscore characters "_" anywhere between digits in a numerical literal
-Not at the beginning or end of a number -Not adjacent to a decimal point -Not prior to an F or L suffix |
|
try-catch with multiple handlers
|
-Each handler is checked in order (top-down)
-The handler that first matches is executed |
|
multi-catch statement
|
-We can combine a catch clause into a single block of code
-If a catch block handles more than one exception type, then the catch parameter is implicitly final -try { } catch(IOException | SQLException ex) { } |
|
AutoClosable
|
Classes that implements AutoClosable can be used as part of try-catch block
try (AutoClosable ae) { } |
|
Handling resources
|
-The new syntax allows to declare resources that are part of the try block.
-The runtime automatically closes the resources after the execution of the try block |
|
Rethrowing exceptions
|
-The Java compiler can determine that the exception thrown by the statement throw "e" must have come from the try block
|
|
Rethrowing exceptions
|
The analysis is disabled if the catch parameter is assigned to another value in the catch block
|
|
Rethrowing exceptions
|
If the catch parameter is assigned to another value, we must specify the exception type Exception in the throws clause of the method declaration
|
|
Rethrowing exceptions
|
The compiler verifies that the type of the rethrown exception meets:
-The try block is able to throw it -There are no other preceding catch blocks that can handle it -It is a subtype or supertype of one of the catch clause's exception parameters |
|
Diamond operator
|
We can replace the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>) as long as the compiler can determine, or infer, the type arguments from the context
|
|
Diamond operator
|
Map<String, List<String>> productMap = new HashMap<String, List<String>>();
Map<String, List<String>> productMap = HashMap<>(); |