Back to Languages

Java Tutorial

Learn Java interactively. Read the concept and write code to practice.

1. Java Introduction

Java is a popular programming language, created in 1995. It is owned by Oracle, ...

2. Java Variables

Variables are containers for storing data values. In Java, there are different t...

3. Data Types

Java data types are divided into two groups: 1. **Primitive data types** - incl...

4. Java Operators

Operators are used to perform operations on variables and values. Java divides ...

5. Java Strings

Strings are used for storing text. A String variable contains a collection of ch...

6. Java Math

The Java Math class has many methods that allow you to perform mathematical task...

7. Java Booleans

Very often, in programming, you will need a data type that can only have one of ...

8. If...Else

Java has the following conditional statements: - `if` to specify a block of cod...

9. Java Switch

Use the `switch` statement to select one of many code blocks to be executed. ``...

10. While Loop

Loops can execute a block of code as long as a specified condition is reached. ...

11. For Loop

When you know exactly how many times you want to loop through a block of code, u...

12. Arrays

Arrays are used to store multiple values in a single variable, instead of declar...

13. Loop Through Arrays

You can loop through the array elements with the `for` loop, and use the `length...

14. Java Methods

A method is a block of code which only runs when it is called. You can pass data...

15. Method Parameters

Information can be passed to methods as parameter. Parameters act as variables i...

16. Classes and Objects

Java is an object-oriented programming language. Everything in Java is associate...

17. Constructors

A constructor in Java is a special method that is used to initialize objects. Th...

18. Java Encapsulation

The meaning of Encapsulation, is to make sure that "sensitive" data is hidden fr...

19. Java Inheritance

In Java, it is possible to inherit attributes and methods from one class to anot...

20. Exceptions (Try...Catch)

When executing Java code, different errors can occur: coding errors made by the ...