Skip to content
wannacode

The language you are learning

Problem

Why Java

There are hundreds of programming languages. Each one is good for something, but not equally good for everything. Before you spend months on one of them, it is fair to know where you will use it.

Java is one of the most widely used languages for programs that run for a long time without stopping:

  • the servers of banks, online stores and booking systems: the part you do not see, but which keeps the accounts and the orders;
  • Android: for a long time this was the main language for Android apps. Today people often write Kotlin there, which runs on the same foundation and can use Java code;
  • large systems in companies and institutions that many people build over many years;
  • Minecraft: the original version of the game (Java Edition) is written in Java.

Java dates from 1995. That is why there is a huge amount of ready-made libraries, documentation and answers to the questions you will run into.

The idea

From text to program

The program you write is plain text in a file. Here is a whole program:

Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Order #1024 has been accepted.");
}
}
Output
Order #1024 has been accepted.

Do not worry about the words in it for now. We will get to them in the lesson "Your first program". What matters here is something else: the computer's processor does not understand this text. Something has to translate it.

  1. You write the source code in a file named Main.java.
  2. The compiler, javac, checks the text for errors and translates it into bytecode: a file named Main.class. Bytecode is not made for any particular processor.
  3. The JVM (Java Virtual Machine) reads the bytecode and runs it on your computer.

There is a JVM for Windows, macOS and Linux. That is why the same Main.class runs on all of them without any change. This is called platform independence.

public class Main {
public static void main(String[] args) {
System.out.println("Order #1024 has been accepted.");
}
}
Step by step, in words
  1. You write the source code: plain text in the file Main.java.
  2. The javac compiler reads the text and checks it for errors.
  3. Out comes bytecode, the file Main.class. It is not made for any particular processor.
  4. The same Main.class goes unchanged to Windows, macOS and Linux.
  5. The JVM on each system runs the bytecode. The output is the same.
More precisely, if you are curious
  • The JVM does not translate the whole program ahead of time. It translates parts of it into machine code while the program runs, and it optimizes harder the parts that run most often. This is called JIT compilation (just-in-time).
  • Memory. Every program takes up memory for its data. In languages like C, the programmer frees the memory that is no longer needed, and if they forget or get it wrong, the program starts taking more and more memory or crashes. Java does this for you: the garbage collector finds the data the program can no longer reach and frees its memory.

The idea

What you will learn

The course is made of modules. Each module uses only things from the ones before it:

  1. Language basics: variables, input and output, calculations, conditions, loops, arrays, text.
  2. Methods: code you write once and call many times.
  3. Classes and objects: your own types, such as Order or Student.
  4. Inheritance and polymorphism: what several types share, in one place.
  5. Errors and exceptions: what the program does when something goes wrong.
  6. Text and files: working with strings, search patterns (regex) and files.
  7. Collections: lists, stack, queue, HashMap.
  8. Modern Java: lambda expressions, Stream and the newer features of the language.
  9. Real-world programs: tests, threads, networking, databases.

Off the main path there are games and projects: whole programs you build step by step.

The two Java features people often point out are in the course too. Threads (several things the program does at the same time) are in "Real-world programs". Reflection (a program that looks at its own classes while it runs) comes in the last modules.

The idea

How you learn here

Each lesson is a series of cards, one idea per card. It usually starts with a real-world problem, then shows what is really going on, often with an animation next to the code. After that comes a small task: predict the output, fill in what is missing, find the bug. At the end there is an exercise you solve in your own editor, and a short quiz.

Your progress is saved in the browser: the lesson picks up from the card you reached.

The map of the whole course is on the course home page.

Do not skip the exercises. Reading code and writing code are different skills, and the second one comes only from writing.

The idea

Errors are part of the job

Your first programs will often not compile. You will forget a semicolon, a quote or a brace, and the compiler will refuse.

This is not a grade on you. The error message is there to help: it tells you which line the problem is on and what it is. Experienced programmers see these messages every day too. The difference is that they have learned to read them calmly. We will start reading them in the very first lesson with code.

If something will not work for a long time, leave it and come back a bit later. Often you spot the error right away when you look at it again.

In short

In short

  • Java runs on servers, on Android, in large systems and in Minecraft.
  • The source code (Main.java) is compiled by javac into bytecode (Main.class), and the JVM runs it on any system.
  • Memory is freed automatically by the garbage collector.
  • The course is made of modules, and each lesson of cards. The exercises are in your own editor.
  • An error message is help, not a grade.

Next comes getting your computer ready: what to install so you can run your first program.

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·