Guide · Java Programming Language
Java Programming Language – Learning Guide
Java is an object-oriented language that runs on any computer with the Java platform installed. It is used for desktop and Android applications, server programs and in teaching programming.
The guide leads from the basics of the language, through classes, objects and collections, to web applications in Spring Boot, graphical applications and physics simulations.
- Secondary school
- Beginner and intermediate level
- Examples in Java
Some lessons linked below are available only in Serbian for now. They are marked (SR).
1 Java basics
The first program, variables, operators, branching, loops, arrays, strings and methods.
Introduction to Java programming
The first program, the Main class and the main method.
Open lesson →Data in Java
Data types, conversions, input (Scanner) and output (printf).
Open lesson →Operators in Java
Arithmetic, relational and logical operators.
Open lesson →Branching in a program
The if-else and switch statements in Java.
Open lesson →Loops in Java
The for, while and do-while loops.
Open lesson →Arrays in Java
Declaring, filling and processing arrays.
Open lesson →Strings in Java (SR)
String and StringBuilder, text methods, equals, split.
Open lesson →Methods in Java (SR)
Parameters, return values, overloading, recursion.
Open lesson →2 Object-oriented programming
Classes and objects are the basis of Java. This part is the most important for further learning.
Classes and objects
Attributes, methods, constructors and creating objects.
Open lesson →Methods and objects
Methods with parameters, return values and working with several objects.
Open lesson →Inheritance
Class hierarchy, superclass and subclass.
Open lesson →Abstract classes and interfaces
Common behaviour of several classes.
Open lesson →Exceptions (SR)
try, catch, finally, throw and your own exceptions.
Open lesson →Object-oriented programming – examples
Tasks with solutions: from the first classes to interfaces.
Open lesson →3 Collections and lambda expressions
Data structures from the Java standard library and processing data with streams.
ArrayList and LinkedList (SR)
Lists, iteration, sorting with a Comparator, queue and stack.
Open lesson →HashMap, HashSet and TreeMap (SR)
Dictionaries and sets: counting, grouping, fast search.
Open lesson →Lambda expressions and the Stream API (SR)
filter, map, sorted, collect, groupingBy.
Open lesson →4 Spring Boot: web applications in Java
Java on the server: REST API, a database and publishing on the internet. You need classes, collections and web basics.
The first web application (SR)
start.spring.io, a controller, routes, a JSON response.
Open lesson →REST API: the Tasks application (SR)
GET, POST, PUT, DELETE, a service, a page with fetch.
Open lesson →Database: Spring Data JPA (SR)
Entity, repository, H2, packaging and publishing.
Open lesson →5 Graphical applications (GUI)
Windows, buttons, drawing and animations.
Dialogs and an introduction to graphics
JOptionPane: dialogs for input, messages and confirmation.
Open lesson →Graphical user interface
Buttons, input fields and labels.
Open lesson →Events in Java
Reacting to a click, a key press and mouse movement.
Open lesson →Drawing in a window
Drawing lines, shapes and text.
Open lesson →Animations in Java
Moving objects with the Timer class.
Open lesson →Example: circular motion (GUI)
An application with a drawing, input fields and a button.
Open lesson →A 2D game: Golf (SR)
A complete example of a game in Java.
Open lesson →Graphical applications – examples
Simple applications with solutions.
Open lesson →6 Physics simulations
Using Java to model physical phenomena.
Java and physics simulations (SR)
How a physical phenomenon is turned into a program.
Open lesson →Loops and arrays in simulations (SR)
Computing motion step by step.
Open lesson →Classes and objects in physics (SR)
Bodies as objects with a position and a velocity.
Open lesson →Simulations in EJS (SR)
Examples of simulations with the necessary theory.
Open lesson →7 Solved tasks in Java
Tasks on the basics and on object-oriented programming.
Exchange of digits – solution
Working with the digits of a number.
Open lesson →Distance between points – solution
A formula and the Math class.
Open lesson →Middle of an interval – solution
A simple task with real numbers.
Open lesson →A group of workers – solution
An array of objects and data processing.
Open lesson →Movement of cars – solution
A class with methods for speed and distance travelled.
Open lesson →Test: classes, objects and methods (SR)
Checking your OOP knowledge.
Open lesson →✎ A short example
The Circle class with a method for the area, and how it is used.
class Circle {
double r; // radius
Circle(double r) {
this.r = r;
}
// area of the circle: r * r * pi
double area() {
return Math.PI * r * r;
}
}
public class Main {
public static void main(String[] args) {
Circle c = new Circle(3);
System.out.println("Area: " + c.area());
}
}
