JAVA BASICS
What is Java?
Java is a widely used, object-oriented programming language designed to let the same program run on different operating systems. Discover how it works, what it can do and its role in modern software development.
The Java programming language
Java was developed at Sun Microsystems and released publicly in 1995. Today, Oracle and a large open-source community develop the language and its platform. Java is used in server systems, financial platforms, business applications, data processing tools and many other areas.
Java is a statically typed language. This means that a variable’s type is known when the program is compiled. The compiler can detect some errors early, and developers can more easily understand the data each part of a program accepts and returns.
How does Java work?
Java source code is first compiled into an intermediate format called bytecode. The Java Virtual Machine, or JVM, executes this code. With a compatible JVM installed, the same compiled program can run on Windows, macOS or Linux without being rewritten for each system.
- Write code in a file with the extension
.java. - The compiler checks the code and creates a
.classbytecode file. - JVM loads and executes the bytecode on the device.
The JDK provides development tools, the JVM executes bytecode, and the libraries needed to run programs form part of the Java environment.
Your first Java program
A simple program can output text to the console:
public class Main {
public static void main(String[] args) {
System.out.println("Labas, Java!");
}
} Execution starts in the method main. The command System.out.println outputs text to the console. Later, you will learn to pass data to a program, store it in variables, check conditions and repeat actions.
Key features of Java
- Object-oriented programming. Code can be organised using classes and objects.
- Type checking. The compiler helps detect incompatible data types.
- Automatic memory management. The garbage collector handles objects that are no longer used.
- A large standard library. It includes tools for collections, files, networking and other everyday tasks.
- A broad ecosystem. Java has mature development tools, libraries and frameworks.
Where is Java used?
Java is often chosen for long-running systems where clear code, reliability and a team’s ability to maintain a large project matter. It is used to build web service backends, banking and insurance systems, ordering platforms, data processing applications and internal organisational tools.
The language is also used in the Android ecosystem, although Kotlin is common in new projects. Learning Java fundamentals makes it easier to understand object-oriented programming, type systems, data structures and principles that are useful when learning other programming languages.
Where should you start?
As a beginner, it helps to study topics in order and practise each one straight away by writing code:
- variables and data types;
- conditions with
ifandelse; forandwhileloops;- arrays and collections;
- methods, classes and objects.
Reading theory alone is not enough. Write a small example, run it, change the initial values and observe the result. This practice helps you remember the syntax and understand how a program executes.