StrizzyG.com

Become a Java Expert

Learn server-side programming with Java.

Java Lessons and Exercises

Lesson 1: Introduction to Java

Java is a popular programming language known for its portability, security, and performance.

Exercise: Write a Java program to print "Hello, World!"


public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
                

Lesson 2: Variables and Data Types

Learn about Java variables and different data types such as strings, integers, floats, and booleans.

Exercise: Declare variables for your name, age, and favorite programming language in Java.


public class VariablesExample {
    public static void main(String[] args) {
        String name = "John Doe";
        int age = 30;
        String favoriteLanguage = "Java";
        System.out.println("Name: " + name);
        System.out.println("Age: " + age);
        System.out.println("Favorite Language: " + favoriteLanguage);
    }
}
                

Lesson 3: Control Structures

Understand Java control structures such as if statements, switch statements, and loops.

Exercise: Write a Java program to display even numbers between 1 to 10.


public class EvenNumbers {
    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++) {
            if (i % 2 == 0) {
                System.out.println(i);
            }
        }
    }
}