Java Tutorial
Java is a strongly typed, object-oriented language that runs on almost any machine through the JVM. These lessons cover the building blocks you need before classes and objects.
1Getting Started
- Your First Java ProgramWhat Java is, how to install the JDK, and how a Java program is structured.
- How Java Works (JDK, JRE, JVM)What happens between writing Main.java and seeing output, and how Java uses memory.
- Variables and Data TypesPrimitive types, String, type conversion and the var keyword.
- Type Casting and Wrapper ClassesConvert between numeric types, and use Integer, Double and friends.
- OperatorsArithmetic, assignment, comparison and logical operators in Java.
- Reading User InputRead numbers and text from the keyboard with the Scanner class.
2Control Flow
3Methods
4Arrays and Strings
5Object-Oriented Programming
- Classes and ObjectsDefine your own types with fields, constructors and methods.
- Constructors and thisOverload constructors, chain them with this(), and use initializer blocks.
- Access Modifiers and PackagesControl who can see your classes and members, and organize code into packages.
- InheritanceExtend classes, override methods and use polymorphism.
- PolymorphismCompile-time and run-time polymorphism, upcasting, downcasting and instanceof.
- InterfacesDefine contracts that many unrelated classes can implement.
- The Object ClasstoString, equals and hashCode, the methods every Java class inherits.
- Nested, Inner and Anonymous ClassesDefine classes inside other classes and create one-off implementations.
- Enums and RecordsModel fixed sets of values with enum, and simple data carriers with record.
6Collections and Generics
- GenericsWrite classes and methods that work with any type while staying type safe.
- ArrayListUse a resizable list that grows and shrinks as you add and remove items.
- HashMapLook values up by key with HashMap and TreeMap.
- The Collections FrameworkAn overview of List, Set, Queue, Deque and Map, and when to use each.
- Sorting with Comparable and ComparatorDefine a natural order for your classes and sort by any field you like.