Java

Virtual threads, sealed types, streams and the modern JVM.

The course

Open the course

Start at 01. The first lesson names the types. The next one builds an object. Each sample is on the page.

  1. Skill

    Basics

    The types, explained, then an object you can name and call.

    1. 01 Java from zero: a variable has a type Start here

      A Java variable has a type. name is a String, cents is an int, and ready is a boolean. The program prints latte $4.50 ready.

      Adds The types this course uses

      2 min read

    2. 02 Java from zero: a class holds the data and the method

      A class groups fields and a method. Item stores a drink and a price in cents. label prints latte $4.50.

      Adds An object you can name and call

      Builds on 12 min read

  2. Practice

    Tips

    A rule that prevents a bug, then a program that uses the object.

    1. 03 Java from zero: null is not an object

      A variable can hold null, which means no object. Calling a method on null fails. The program checks first and prints missing.

      Adds A tip that prevents a bug

      Builds on 1 through 22 min read

    2. 04 Java from zero: int division drops the fraction

      Dividing two ints drops the fraction. A $5.00 bill split three ways is 166 cents each, not 166.666. The program prints 166. Two cents are left over.

      Adds A program that uses the object

      Builds on 1 through 32 min read

  3. Further

    A whole program

    One more idea, then a program that puts the pieces together.

    1. 05 Java from zero: a record keeps the cents

      A record is a small object with fields the constructor sets. Money holds cents. Adding three lattes of 450 prints 1350.

      Adds A program that puts the pieces together

      Builds on 1 through 42 min read

    2. 06 Java from zero: one method is enough to call

      An interface is the method list a function needs. Labeller asks for label. Item has label. show prints latte $4.50.

      Adds A program that puts the pieces together

      Builds on 1 through 52 min read

GoByte Skills: Java track, 3 lessons. Virtual threads, sealed types and streams: modern Java that the compiler and runtime check for you.

Open the Java track

Articles

RSS
  • Streams: nothing runs until the end

    GoByte Skills #6: filter and map do not filter or map anything. They write down a recipe, and no element moves until a terminal call drives the pipeline, pushing elements through one at a time. Bonus: why count() can skip your peek.

  • Sealed types: the switch that cannot forget

    GoByte Skills #5: Seal the hierarchy, drop the default, and adding a type turns every switch that missed it into a compile error with a line number.

  • Virtual threads: blocking is cheap again

    GoByte Skills #4: 10,000 tasks that each sleep 1 s finish in about 1.1 s on a 14 core laptop, in plain blocking Java. Virtual threads park and free the carrier. The catch on Java 21: synchronized pins it.