Programming and IT
How to learn Java from scratch
Java is a strictly typed language behind banking systems, the servers of large services and Android apps. The strictness slows you down at first, but the compiler catches many mistakes before the program ever runs. This plan takes about six months at an hour a day and leads from your first program to a small backend application.
In this article
What to install#
You need a JDK — the development kit that contains the javac compiler and the
runtime. Take the current LTS release: OpenJDK builds are free (Eclipse Temurin,
for example). For an editor, use IntelliJ IDEA Community Edition: it is free and
flags errors right in the editor as you type.
Build your first program by hand once, without the IDE, so you see what actually happens:
javac Hello.java turns the source into the bytecode file Hello.class, and
java Hello runs it. Recent JDKs can also run a single-file program directly:
java Hello.java.
Weeks 1–6: the language without objects#
Primitive types (int, long, double, boolean, char) and how they differ
from reference types, strings and why they are immutable, operators, if,
switch, loops, arrays, static methods. Pay attention to integer division and
overflow: 7 / 2 in Java gives 3, and the sum of two large int values can
turn negative. Good tasks for this stage: converting between number bases,
finding prime numbers, working with an array of grades.
Weeks 7–12: object-oriented programming#
Classes and objects, fields and constructors, encapsulation, inheritance,
interfaces and abstract classes, polymorphism. Work through equals, hashCode
and toString — many beginners trip over them. To make it stick, model a small
domain: a library with books, readers and loans, or bank accounts with transfers
and a transaction history. Learn exceptions at the same time: checked and
unchecked, and your own exception classes.
Weeks 13–18: the standard library and tools#
- Collections:
ArrayList,HashMap,HashSet,LinkedList— when to use which and how fast their operations are. - Generics, lambdas and the Stream API.
- Building a project with Maven or Gradle: dependencies and the
src/main/java/src/test/javalayout. - Unit tests with JUnit 5.
- Git: a branch per task and meaningful commits.
Weeks 19–26: towards backend development#
Talk to a database through JDBC, then get to know Spring Boot — the framework most server-side Java is written with. The final project is a REST service, such as a to-do list or a book tracker: a few endpoints, storage in PostgreSQL, tests and a README that explains how to run it.
Projects worth showing#
- a console tic-tac-toe game with win detection and tests;
- a CSV parser that computes statistics and writes a report to a file;
- bank accounts with transfers and protection against going below zero;
- a Spring Boot REST service backed by a database.
How to check yourself#
Run the tests before every commit and keep them green. Turn on static analysis in the IDE and deal with every warning instead of switching it off. Solve problems on sites with automatic checking, such as Exercism or LeetCode, choosing Java as your language. Every two weeks, reread your old code and rewrite whatever you would now do differently — it is the clearest sign of progress. If you can, post a project for code review in a Java community, for example the Code Review site on Stack Exchange.
Step-by-step plan
- Week 1 — JDK and IDEInstall an LTS JDK and IntelliJ IDEA, compile your first program by hand with javac.
- Weeks 2–6 — language basicsTypes, operators, conditions, loops, arrays, static methods.
- Weeks 7–12 — OOPClasses, inheritance, interfaces, equals and hashCode, exceptions.
- Weeks 13–18 — library and toolsCollections, generics, the Stream API, Maven or Gradle, JUnit 5, Git.
- Weeks 19–26 — a backend projectJDBC, Spring Boot, a REST service with a database and tests.
Start learning this in your own space
The plan goes into your repository: tick off stages, keep notes — the change history shows how far you have come.
Check yourself
1.What does this Java code print: System.out.println(7 / 2);
2.What does this Java code print: System.out.println("a" + 1 + 2);
3.What is the value of the expression 10 % 3 in Java?
Sources
-
dev.java — LearnOfficial Java learning material from Oraclefree
-
The Java TutorialsOracle's classic tutorial on the language basicsfree
-
JUnitUser guide for unit testing in Javafree
-
Exercism — Java trackFree exercises with automated tests and optional mentoringfree
Was this helpful?