Skip to content
Justice Tech School

Java Tutorial

Object oriented programming for apps, back ends and Android.

Start learning Java
Getting started4 lessons
  1. 1Java IntroductionWhat Java is and why it is used.
  2. 2Setup and Program StructureJDK, classes and the main method.
  3. 3Outputprint, println and printf.
  4. 4CommentsNotes the compiler ignores.
Basics23 lessons
  1. 5VariablesStoring values with types.
  2. 6Data TypesPrimitive and reference types.
  3. 7Type CastingConverting between types.
  4. 8OperatorsArithmetic, comparison and logic.
  5. 9StringsWorking with text.
  6. 10The Math ClassRounding, powers and random numbers.
  7. 11Booleans and Conditionstrue, false and comparisons.
  8. 12Java String MethodsStrings are immutable objects.
  9. 13StringBuilder and FormattingStringBuilder builds text efficiently.
  10. 14Wrapper Classes and AutoboxingEach primitive has a wrapper: Integer, Double, Boolean, Character.
  11. 15var and finalvar lets the compiler infer a local type.
  12. 16Bitwise Operators and Ternary& | ^ ~ << >> operate on bits.
  13. 17Variables and ConstantsDeclare a variable with its type.
  14. 18var Type Inferencevar lets the compiler infer a local variable type.
  15. 19Primitive TypesJava has byte, short, int, long, float, double, char and boolean.
  16. 20Type CastingWidening conversions are automatic.
  17. 21Math ClassMath has abs, max, min, pow, sqrt, round, floor, ceil and random.
  18. 22String MethodsStrings are immutable.
  19. 23String.format and Text BlocksString.format and printf use %s, %d, %.2f.
  20. 24StringBuilderStringBuilder changes text without creating many strings.
  21. 25Reading Input with ScannerScanner reads from System.in or from a string.
  22. 26OperatorsArithmetic, comparison, logical, assignment and bitwise operators.
  23. 27Wrapper Classes and ParsingInteger, Double and Boolean wrap primitives.
Control flow16 lessons
  1. 28If ... ElseMaking decisions.
  2. 29SwitchChoosing between many values.
  3. 30While LoopsRepeating while a condition holds.
  4. 31For LoopsCounting loops and the for-each loop.
  5. 32Break and ContinueControlling loops.
  6. 33ArraysFixed size lists.
  7. 34Switch Expressions and Pattern MatchingModern switch uses arrows, returns a value and needs no break.
  8. 35Nested Loops and PatternsLoops can be nested to build tables and patterns.
  9. 36if, else if and elseBranch on conditions.
  10. 37switch ExpressionsThe arrow form returns a value, needs no break and can group cases.
  11. 38for Loopsfor has init, condition and update.
  12. 39while and do whilewhile checks first, do while runs once before checking.
  13. 40break, continue and Labelsbreak leaves a loop, continue skips a round and a label exits nested loops.
  14. 41ArraysArrays have a fixed size.
  15. 42Two Dimensional ArraysAn array of arrays models grids and tables.
  16. 43Arrays UtilitiesArrays.sort, fill, copyOf, equals, asList and binarySearch save work.
Methods10 lessons
  1. 44MethodsReusable blocks of code.
  2. 45Method OverloadingSame name, different parameters.
  3. 46RecursionA method that calls itself.
  4. 47Varargs and Pass by ValueA varargs parameter accepts any number of arguments.
  5. 48Static Methods and Utility Classesstatic methods belong to the class and are called without an object, like Math.max.
  6. 49MethodsMethods have a return type, name and parameters.
  7. 50Method OverloadingMethods may share a name with different parameters.
  8. 51VarargsType.
  9. 52RecursionA method can call itself.
  10. 53Pass by ValueJava passes copies.
Object oriented programming21 lessons
  1. 54Classes and ObjectsBlueprints and instances.
  2. 55ConstructorsSetting up new objects.
  3. 56Access Modifiers and EncapsulationHiding data behind methods.
  4. 57InheritanceBuilding on another class.
  5. 58PolymorphismOne reference, many forms.
  6. 59Abstract Classes and InterfacesContracts for classes.
  7. 60Static Members and EnumsClass level data and fixed sets of values.
  8. 61Object, toString, equals and hashCodeEvery class extends Object.
  9. 62Inner, Nested and Anonymous ClassesA class can live inside another class.
  10. 63Sealed Classes and RecordsA record is an immutable data class with generated constructor, accessors, equals and toSt.
  11. 64Classes and ObjectsA class defines fields and methods.
  12. 65EncapsulationMake fields private and expose getters and setters with checks.
  13. 66Inheritanceextends inherits from a class.
  14. 67PolymorphismA parent type variable can hold any child.
  15. 68Abstract Classes and InterfacesAbstract classes share code and force children to implement methods.
  16. 69static Fields and Methodsstatic members belong to the class, not to objects.
  17. 70this and superthis refers to the current object and super to the parent.
  18. 71EnumsAn enum defines fixed constants.
  19. 72RecordsA record is a short immutable class with auto constructor, getters, equals and toString.
  20. 73GenericsGenerics add a type parameter so one class works for many types safely.
  21. 74equals, hashCode and toStringOverride equals and hashCode together and toString for readable output.
Collections and modern Java21 lessons
  1. 75ArrayListA list that can grow.
  2. 76HashMap and HashSetKey and value pairs, and unique values.
  3. 77Lambdas and StreamsShort functions and data pipelines.
  4. 78Records and Text BlocksModern shortcuts.
  5. 79List, Set, Queue and DequeThe Collections Framework offers List (ordered), Set (unique), Queue and Deque (FIFO and d.
  6. 80Maps In DepthHashMap is fast and unordered, LinkedHashMap keeps insertion order and TreeMap sorts by ke.
  7. 81Java GenericsGenerics let classes and methods work with many types safely.
  8. 82Streams and CollectorsStreams process collections declaratively: filter, map, sorted, distinct, limit, reduce an.
  9. 83OptionalOptional models a value that may be absent.
  10. 84Sorting and ComparatorsComparable defines natural order and Comparator defines custom orders.
  11. 85Date and Time APIjava.time provides LocalDate, LocalDateTime, Duration, Period and DateTimeFormatter.
  12. 86ArrayListArrayList is a resizable list.
  13. 87HashMapHashMap stores key value pairs.
  14. 88HashSetA set holds unique values.
  15. 89Iterating CollectionsUse for each, forEach with a lambda, or Iterator when removing while looping.
  16. 90Sorting and ComparatorsCollections.sort and List.sort use natural order or a Comparator.
  17. 91LambdasA lambda is a short anonymous function: (a, b) -> a + b.
  18. 92StreamsStreams process collections with map, filter and collect.
  19. 93OptionalOptional holds a value or nothing and avoids null checks.
  20. 94Queue and DequeQueue is first in first out and Deque works at both ends.
  21. 95Switch Patterns and instanceofPattern matching tests a type and names it in one step.
Errors and files9 lessons
  1. 96Exceptionstry, catch, finally and throw.
  2. 97Reading and Writing FilesThe java.nio.file API.
  3. 98User Input with ScannerReading from the keyboard.
  4. 99Custom Exceptions and try with resourcesCreate your own exception by extending Exception (checked) or RuntimeException (unchecked).
  5. 100Files with java.nioFiles and Path read and write whole files in one line, list directories and walk trees.
  6. 101try, catch, finallyHandle errors with try catch.
  7. 102Custom ExceptionsExtend Exception for your own error types.
  8. 103try with resourcesResources that implement AutoCloseable close automatically.
  9. 104Files with java.nioFiles.writeString and readAllLines are the modern way to handle small files.
Advanced JavaPremium6 lessons
  1. 105Threads and ExecutorsThreads run work concurrently.
  2. 106Synchronization and Atomicssynchronized, ReentrantLock and the atomic classes protect shared data from race condition.
  3. 107CompletableFuture and Virtual ThreadsCompletableFuture chains asynchronous steps with thenApply and thenCombine.
  4. 108Reflection and AnnotationsReflection inspects classes at runtime.
  5. 109Composition, SOLID and Design PatternsPrefer composition to inheritance, program to interfaces and follow SOLID.
  6. 110JVM, Memory and Garbage CollectionThe JVM runs bytecode.
Java in practicePremium8 lessons
  1. 111Maven and GradleMaven and Gradle download dependencies, compile, test and package.
  2. 112Testing with JUnitJUnit 5 is the standard test framework.
  3. 113JSON with Jackson or GsonLibraries such as Jackson and Gson convert objects to JSON and back.
  4. 114HTTP Client and RESTjava.net.http.HttpClient sends requests and receives responses, synchronous or async.
  5. 115Spring Boot OverviewSpring Boot builds production web apps with minimal setup.
  6. 116Databases with JDBC and JPAJDBC runs SQL from Java with prepared statements.
  7. 117Logging and ConfigurationUse a logging framework (SLF4J with Logback) instead of System.out.
  8. 118Java Best PracticesFollow naming conventions, prefer immutability, use interfaces, avoid null, close resource.
Next steps2 lessons
  1. 119What Next?Where to go after the basics.
  2. 120Practice ProjectsBuild a library system with a database, a REST API with Spring Boot, a command line game a.