reading-notes

Maps, primitives, File I/O

Java Primitives versus Objects

Java Type System

Integer j = 1;          // autoboxing
int i = new Integer(1); // unboxing

Pros and Cons

Conclusion

Exceptions in Java

What Is an Exception?

The Catch or Specify Requirement

Example on how to throw an Exceptions

public Object pop() {
    Object obj;

    if (size == 0) {
        throw new EmptyStackException();
    }

    obj = objectAt(size - 1);
    setObjectAt(size - 1, null);
    size--;
    return obj;
}

1- Any exception thrown directly by the method with the throw statement

2- Any exception thrown indirectly by calling another method that throws an exception

Scanning

Objects of type Scanner are useful for breaking down formatted input into tokens and translating individual tokens according to their data type.