Java fundamentals
You learn Java, widespread in enterprise systems, from scratch, moving from variables to object-oriented design and safe error handling.
Level 101 · 26 lessons · 21 practice labs
Lessons
Getting started
- The JDK, the JVM and a first program: javac and java: You understand how Java is compiled and run on a virtual machine, and run your first program with javac and java.
- Variables and primitive types: You know int, double, boolean and char, how much space each takes and what each is suited for.
- Operators, casting and overflow: You use arithmetic and logical operators and learn how type conversion works and what happens when a number exceeds its limit.
- String, StringBuilder and text handling: You treat text as immutable objects, use concatenation, splitting and searching, and choose StringBuilder inside loops.
- Reading keyboard input with Scanner: You write small console programs that read numbers and text from the user.
- Short task: a program that prints a shopping receipt
Control flow and data
- Conditions: if, else and switch: You make programs decide using if-else chains and switch expressions, and learn the comparison pitfalls.
- Loops: for, while, do-while: You write repeated work with the right loop and steer it with break and continue.
- Methods: parameters, return values and overloading: You split code into reusable methods and overload one name with different parameters.
- Arrays and multi-dimensional arrays: You create and traverse fixed-size arrays and see why access outside the bounds raises an error.
- ArrayList: lists that can grow: You hold data that changes in size with ArrayList, adding, removing and iterating over elements.
- Short task: a program that computes statistics from a list of marks
Object-oriented basics
- Classes, objects and constructors: You write your own class, create objects through constructors and relate objects to each other.
- Encapsulation: access modifiers and getters/setters: You make fields private, expose them through controlled methods and block invalid values inside the object.
- Static members and constants with final: You use members shared by a class and protect values that must not change with final.
- Inheritance and super: You derive one class from another, keep shared behaviour in the parent and reach it with super.
- Polymorphism and method overriding: You use a parent-typed variable with different subclass objects and change behaviour with @Override.
- Interfaces and abstract classes: You define the contract classes must follow with an interface and choose between an interface and an abstract class.
- Short task: bank account classes with validation
Error handling, files and projects
- Error handling: try, catch, finally: You catch errors, guarantee cleanup with finally and learn to read stack traces.
- Checked exceptions and custom exception classes: You know the difference between checked and unchecked exceptions and write your own exception class.
- Reading and writing files: java.nio.file and try-with-resources: You read and write files with Files and Path and close resources automatically with try-with-resources.
- Packages and project layout with Maven: You organise code into packages and learn to build a project and add dependencies with Maven.
- Input validation and safe error messages: You validate outside data before using it and keep sensitive details out of error messages.
- Short task: a CSV loader that skips and reports bad rows
Capstone
- Capstone: a command-line program that summarises log lines: You combine what you learned into a Java program that reads a log file, counts event types and prints a summary.
Practice labs
- Sharing a bill with tip to kuruş precision: Write a method that takes a total and a tip rate and computes each person's share to kuruş precision.
- Finding the decimals lost in a cast: Fix an average calculation that always rounds down because of integer division and a cast in the wrong place.
- Catching silent overflow with Math.addExact: Fix Mavikaya Lojistik's yearly mileage total, which goes negative through int overflow, with long and Math.addExact and pass the boundary tests.
- Producing initials from a full name: Write a method with String methods that returns upper-case initials from a full name with extra spaces.
- Building receipt lines with StringBuilder: Rewrite a receipt builder that accumulates strings with + in a loop using StringBuilder and String.format to produce aligned columns.
- Repairing the skipped-line bug with Scanner: Fix a registration program that skips the name because nextLine returns empty after nextInt and make it ask again on non-numeric input.
- Finding the type of day with switch: Write a method with an arrow-form switch expression that returns weekday or weekend from a day name.
- Finding the years needed to reach a target amount: Compute with a loop the years needed to reach a target with yearly interest, handling zero interest and an already-met target.
- Fixing the wrong overload being chosen: Find the places where implicit conversion makes the wrong version of a discount method with int and double overloads get called, clarify the signatures and pass the tests.
- Locating the smallest and largest value in an array: Write a method that returns the indices of the lowest and highest values in a temperature array.
- A seat map in a two-dimensional array: Keep hall seats in a two-dimensional array and write methods finding free seats per row and the first two adjacent free seats.
- Fixing items skipped when removing in a loop: Fix clean-up code that calls remove while iterating by index and picks the wrong overload on an integer list, passing the consecutive-removal tests.
- Writing a constructor and toString for a product class: Add a constructor, toString and a stock-value method to a class with name, price and stock fields.
- Guarding a thermostat setting with a range: Make public fields private, apply a range check in the setter and test that state is unchanged on an invalid value.
- Finding a shared static field bug: Fix a class where every order gets the same number because a field meant to be per object is static, and make the constants final.
- Initialising a subclass with super: Derive a manager class from employee, call super in the constructor and override the salary calculation to add a bonus.
- Polymorphism with a Payable interface: Give invoice and salary classes a common interface and write a method computing total payment over a single list.
- Fixing an overload-instead-of-override trap: Use @Override to expose and fix shape classes that misbehave because a method and equals with a different parameter type never override.
- Handling a bad number with try-catch: Write a method reading an age from text that catches NumberFormatException and throws its own checked exception with a meaningful message.
- A CSV loader that skips and reports bad rows: Read a student file with java.nio.file and try-with-resources, skip bad rows and report each with its line number and reason.
- Input validation and safe error messages: In a registration program that shows users stack traces and file paths, validate inputs, give users a generic message and write details only to the log.
About this course
You learn Java, widespread in enterprise systems, from scratch, moving from variables to object-oriented design and safe error handling.
What you will learn
- Getting started
- Control flow and data
- Object-oriented basics
- Error handling, files and projects
- Capstone
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.