Skip to content
SparkTime, home

Tagged #Java basics

GuideTechnology

29 min read

Project 1: Build an Expense Tracker CLI in Plain Java

Build your first complete Java application: a command-line expense tracker with a clear design, money handled correctly, a file-based repository behind an interface, automated tests, a Maven build, and a runnable jar, then review it honestly.

GuideTechnology

18 min read

Debugging: Errors, Stack Traces, the Debugger and Logging

A method for finding bugs instead of guessing: read compiler errors and stack traces properly, form and test hypotheses, use breakpoints and stepping in a debugger, log usefully at the right level, and reach for thread dumps and heap dumps when the problem is a hang or a leak.

GuideTechnology

16 min read

File I/O and Serialization

How to read and write files in modern Java with Path and Files, why character encoding matters, how to stream large files safely, how to avoid path traversal, and what Java serialization really is, why it is risky, and what to use instead.

GuideTechnology

12 min read

Null and Optional

Why null causes so many bugs, what Optional is actually for, how to use map, flatMap, orElse, orElseGet and orElseThrow, and the common misuses (fields, parameters, get without a check). Optional is a tool for return values, not a universal replacement for null.

GuideTechnology

12 min read

Lists and Sets

How Java's collections framework is organised, how ArrayList and LinkedList really differ, what makes a Set unique, how to remove items safely while iterating, and the confusing differences between List.of, Arrays.asList and unmodifiable views. Includes sequenced collections from Java 21.

GuideTechnology

12 min read

Exceptions: Handling Errors Properly

How Java reports and handles errors: the exception hierarchy, checked versus unchecked exceptions and why opinions differ, try, catch, finally and try-with-resources, custom exceptions, exception chaining, and the habits that separate good exception handling from swallowed errors.

GuideTechnology

12 min read

Enums, Records and Sealed Types

How to model data precisely in modern Java: enums for fixed sets of values, records for immutable data carriers, and sealed types with pattern matching for a closed set of alternatives. Each is introduced from the bug it prevents, and compared with the older style you will still see.

GuideTechnology

13 min read

Strings, StringBuilder, Text Blocks and Time

Why Java strings are immutable and what the string pool really is, when to use StringBuilder, how Unicode makes length surprising, how text blocks and formatting work, and how to handle dates and times with java.time instead of the old Date and Calendar. Includes testable time with Clock.

GuideTechnology

12 min read

equals, hashCode, toString and the Object Contract

Why two objects that look identical are not equal by default, what == really compares, how to write equals and hashCode correctly, why mutable keys break HashSet and HashMap, and how immutability makes all of this safer. Includes the Integer cache surprise and the contracts interviewers ask about.

GuideTechnology

11 min read

Inheritance, Overriding and Overloading

How one Java class can build on another, how overriding changes behaviour at runtime, how overloading is chosen at compile time, and why inheritance is easy to misuse. With the constructor-order trap, field hiding and the exact differences interviewers ask about.

GuideTechnology

12 min read

Classes, Objects and Encapsulation

Why object-oriented programming exists and how Java expresses it: classes as blueprints, objects as instances, constructors, access modifiers, static versus instance members, and encapsulation as a way to protect the rules of your data. Built around a bank account that cannot go wrong.

GuideTechnology

13 min read

Decisions, Loops, Methods and Scope

How to make a Java program choose and repeat: if, switch (old statement and modern expression), the loop forms, and how to organise code into methods. Includes the pass-by-value rule that interviewers love and the scope rules that cause mysterious compile errors.

GuideTechnology

15 min read

Variables, Types, Operators and Arrays

How Java stores and combines data: primitive types versus references, what happens when a number overflows, why integer division surprises people, how casting and conversion work, when to use var, and how arrays hold a fixed number of values.

GuideTechnology

15 min read

Start Here: What Java Is, How It Runs and Your Roadmap

What Java actually is, how a .java file becomes a running program, what the JDK, JRE and JVM each do, and how to compile and run your first program. Plus the full roadmap of this 41-article course, from zero to a tested Spring Boot API.

GuideTechnology

21 min read

Java Essentials for DSA

Only the Java you need for data structures and algorithms: types and overflow, loops, methods, arrays, strings, a small class, input and output, and the mistakes that trip up almost every beginner.