Book Cover
Core Java Volume 1 -- Fundamentals

★ ★

TL;DR: More of a reference book than a read-through book. Goes through the Java core API


Note: skipped over Ch 10-14 (Graphics, Events, UI, Deployments, Concurrency)

1: An Introduction to Java

  • Buzzwords from white paper:
    • Simple
    • Object-oriented
    • Distributed
    • Robust
    • Secure
    • Architecture-Neutral
      • Can run on many processors given the presence of the JVM. Compiler generates bytecode
    • Portable
    • Interpreted
    • High-performance
    • Multithreaded
    • Dynamic

2: The Java Programming Environment

  • Primitives: int (4 bytes), short (2 bytes), long (8 bytes), byte (1 byte), float (4 bytes), double (8 bytes), char (1 byte), boolean (1 bit)

3: Fundamental Programming Structures in Java

  • Declare variables where they are used
  • Strings are immutable
  • Can memorize print format characters or time format characters if ever inclined
    • Should do regex at some point too
  • labeled break: break out of outer loop

4: Objects and Classes

  • OO-programming: data then algorithms
  • Object has behavior, state, and identity
    • what you can do with the object
    • how the object reacts when behavior is invoked
    • how to distinguish object from others with same behavior/state
  • Classes are nouns, methods are verbs
  • Implicit parameter of an instance method is the instance (target, receiver)
  • Always use clone to return a copy of a mutable field
  • Static methods when method doesn’t need access to object state
  • Method:
    • Cannot modify parameter of primitive type
    • Can change state of object parameter
    • Cannot make pobject parameter refer to new object
  • list.add(3) autoboxes to list.add(Integer.valueOf(3))

5: Inheritance

6: Interfaces, Lambda Expressions, and Inner Classes

  • Interface: benefits of multiple inheritance while avoiding complexities and inefficiencies
  • Lambda: block of code that can be passed around to use later, once or many times
    • Deferred execution

7: Exceptions, Assertions, and Logging

  • RuntimeException comes from programming error. Any other exception is because something happened to your otherwise good program
  • Use the finally clause to close a resource

8: Generic Programming

  • Generics get wild
  • Raw type is created whenever generic is defined
    • Type variables erased and replaced by their bounding types
  • Wildcard type allows type parameter to vary
    • Example: Pair<? extends Employee>

9: Collections