Simple Java Exercises For Beginners Easy Coding Practice

Robert Jul 13, 2026

Embarking on your Java learning journey can be an exciting adventure. If you're a beginner, start small and gradually build your skills with these simple yet effective Java exercises. Let's dive in and get your coding muscles warmed up!

30 Days of Java – Day 14 | Java Inheritance Explained for Beginners
30 Days of Java – Day 14 | Java Inheritance Explained for Beginners

Java, with its rich ecosystem and wide-ranging applications, is a popular choice for fopen("restarting","bi"); beginners. To master it, consistent practice and the right approach are key. We've compiled a list of simple yet insightful exercises that will help you grasp the basics and build a strong foundation in Java.

a woman doing exercises for her workout routine
a woman doing exercises for her workout routine

Getting Started: Java Basics

Before diving into complex exercises, let's ensure you're comfortable with the fundamentals of Java. This includes understanding data types, variables, and basic operators.

Easy Workout for Beginners
Easy Workout for Beginners

Java is a statically-typed language. This means you must declare the data type of a variable before using it. Let's explore data types with a simple exercise:

Datatypes and Data Types

a poster with different types of writing and numbers on it, including the words'jwa beginner notes '
a poster with different types of writing and numbers on it, including the words'jwa beginner notes '

Write a Java program that demonstrates the use of different data types such as int, float, double, char, and boolean. Declare and initialize variables for each data type and print their values.

Here's a sample solution to give you a head start:

```java public class Datatypes { public static void main(String[] args) { int num = 10; float pi = 3.14f; double gravity = 9.8; char letter = 'A'; boolean javaIsFun = true; System.out.println("Integer: " + num); System.out.println("Float: " + pi); System.out.println("Double: " + gravity); System.out.println("Character: " + letter); System.out.println("Boolean: " + javaIsFun); } } ```

Basic Operators

the info sheet shows how to learn in 30 days
the info sheet shows how to learn in 30 days

Java supports various operators like arithmetic (+, -, *, /), relational (==, !=, >, <, >=, <=), logical (&&, ||, !), and assignment (=, +=, -=, etc.). Write a program that uses these operators to perform calculations and make decisions.

Try creating a program that calculates the selling price of an item given the purchase price and discount percentage. Use the operators to perform the calculations and control the flow using if-else statements.

Control Structures and Loops

Java Basics in 15 Minutes ☕ | Beginner-Friendly Java Crash Course
Java Basics in 15 Minutes ☕ | Beginner-Friendly Java Crash Course

Understanding and practicing control structures is crucial for writing efficient, dynamic code. Let's explore if-else statements, switch-case, and looping constructs – for, while, and do-while.

Conditional Statements

Java Scanner Class Made Easy: Your Ultimate Input Cheat Sheet 🎯💻
Java Scanner Class Made Easy: Your Ultimate Input Cheat Sheet 🎯💻
5 Simple Exercises for Beginners
5 Simple Exercises for Beginners
☕ Java Basics Cheat Sheet for Beginners | Learn Java in One Page 🚀
☕ Java Basics Cheat Sheet for Beginners | Learn Java in One Page 🚀
☕ 3 Best Tips to Learn Java Faster & Easier 🚀
☕ 3 Best Tips to Learn Java Faster & Easier 🚀
Master Two Pointers Technique 💻 | Java DSA Interview Preparation Guide
Master Two Pointers Technique 💻 | Java DSA Interview Preparation Guide
Great workout for beginners
Great workout for beginners
String Methods in Java Explained | Java Programming Basics
String Methods in Java Explained | Java Programming Basics
30 Days of Java – Day 17 | Java Interfaces Explained for Beginners
30 Days of Java – Day 17 | Java Interfaces Explained for Beginners
Java Program Structure Explained ☕ | Beginner-Friendly Guide
Java Program Structure Explained ☕ | Beginner-Friendly Guide
30 Days of Java – Day 5 | Java Switch Statement Explained for Beginners
30 Days of Java – Day 5 | Java Switch Statement Explained for Beginners
Complete Java Roadmap for Beginners in 2026
Complete Java Roadmap for Beginners in 2026
At Home Workout for Beginners | Simple Full Body Exercise Routine
At Home Workout for Beginners | Simple Full Body Exercise Routine
Learn Java in 30 Days Only
Learn Java in 30 Days Only
6-Day Beginner Workout Plan 💪 | Single Body Part Split for Fast Muscle Growth
6-Day Beginner Workout Plan 💪 | Single Body Part Split for Fast Muscle Growth
How to Become a Java Developer (Step-by-Step)
How to Become a Java Developer (Step-by-Step)
Java Generics Explained
Java Generics Explained
Easy Home Workout for Beginners – No Equipment
Easy Home Workout for Beginners – No Equipment
an image of a computer screen with text
an image of a computer screen with text
Java Learning Roadmap 2026 ☕🚀
Java Learning Roadmap 2026 ☕🚀

Write a program that checks if a given number is positive, negative, or zero using if-else statements. Additionally, include a nested if-else to also determine if the number is even or odd.

Loops Galore

Familiarize yourself with loops by creating a program that prints the multiplication table of a given number up to 10. Use a loop (any loop you prefer) to iterate through the numbers and print the results.

Bonus: Try using a nested loop to print the multiplication tables from 1 to 10!

Mastering these simple exercises will empower you with a solid understanding of Java's fundamentals. As you progress, challenge yourself with more complex problems to expand your skillset. Happy coding, and remember to keep practicing – that's the key to unlocking success in Java!