ProgrammingIntermediateJava

Java Programming Fundamentals

Objects and references, the String and generics model, the collections framework, exceptions, the Stream API and the concurrency essentials.

Java's reputation as verbose is a side effect of a design that puts everything in a class and states types twice. Underneath that, four ideas do most of the work, and this course is built around them. First, **Java has no value types**. Every variable holds a reference, so passing an argument copies the reference and not the object. That single fact explains why `==` on strings is a bug, why arrays are not compared by their contents, and why a method that "modifies its argument" may or may not be visible to the caller. Second, **`String` is immutable**, and immutability is not a limitation but the reason it is safe to share, to use as a map key, and to hand to code that runs on another thread. Third, **generics are erased**. `List<String>` and `List<Integer>` are the same type at run time, which is why you cannot write `new ArrayList<String>()` polymorphically, and why a raw `List` accepts anything without complaint. Fourth, **checked exceptions** put failure in the method signature. It is controversial and it is also the only mainstream language that makes "this can fail" part of a type. The course ends with concurrency, where the memory model decides what another thread is allowed to see.

4.7 (120) 1,380 students 83 min 9 lessons 200 XP on completion

What you will be able to do

  • Explain that every Java variable holds a reference, and predict what a method can and cannot change about its arguments
  • Distinguish == from equals, and know why String requires the latter
  • Use generics and understand what type erasure takes away
  • Pick the right collection for a requirement, and know the cost of each choice
  • Handle exceptions with try-with-resources rather than finally blocks
  • Write a Stream pipeline and say when a plain loop is the better answer
  • Explain what volatile and synchronized actually guarantee, and what they do not

Assessments

Module 3: The Collections Framework

1 lessons

Module 5: Streams and Functional Style

1 lessons
Dashboard