Skip to content

Repository files navigation

Java Basics Learning

A hands-on Java learning repository containing beginner-friendly examples, exercises, and coding challenges. The project is organized by topic so that Java fundamentals can be learned and practiced step by step.

📚 Learning Roadmap

This repository follows a structured Java learning path, from the fundamentals of Java programming through practical exercises and challenges.

Section 1 — Getting Started with Java Programming

The introductory section covers:

Course introduction and Java development roadmap

Java 17 and updated course material

Video quality and learning resources

Using subtitles effectively

Getting help through Q&A

Source-code access and hands-on coding practice

Persistence and a growth mindset in programming

Choosing the right Java version and understanding Long-Term Support (LTS)

Section 2 — Java Development Environment Setup

The development environment section covers:

Essential Java development tools — JDK 17 and IntelliJ IDEA

Installing JDK 17 on Windows 10/11

Installing JDK 17 on macOS, including Intel and Apple Silicon Macs

Installing OpenJDK 17 on Ubuntu Linux

Verifying the Java installation and using JShell

Section 3 — First Steps in Java Programming

The Java fundamentals section covers:

Writing the first Java program with Hello World and basic error handling

Variables, keywords, and the int data type

Using variables in Java expressions

Java primitive types, integer ranges, and wrapper classes

byte, short, and long data types

Casting with numeric primitive types

Primitive types challenge using integer variables

float and double and floating-point precision

Floating-point precision challenge

char and boolean primitive data types

Recap of primitive types and introduction to the String class

Operators, operands, and expressions

Abbreviated operators for concise Java code

Section 4 — Transitioning from JShell to IntelliJ IDEA

The IDE section introduces professional Java development with IntelliJ IDEA:

Understanding the power of an Integrated Development Environment (IDE)

What is an IDE?

Installing IntelliJ IDEA on Windows

Installing IntelliJ IDEA on macOS

Installing IntelliJ IDEA on Linux

Configuring IntelliJ IDEA for Windows

Configuring IntelliJ IDEA for Linux

Creating the first IntelliJ project with a Hello World Java implementation

Understanding IntelliJ code structure: classes, methods, and basic Java syntax

Using Java if-then statements for conditional program flow

Implementing logical AND (&&) in Java conditions

Implementing logical OR (||) in Java conditions

Understanding assignment (=) versus equality (==)

Using Java's ternary operator for concise conditions

Understanding Java operator precedence

Applying operator precedence through a practical challenge

Section 5 — Mastering Java Expressions, Statements, Code Blocks, and Method Overloading

This section focuses on Java workflow, expressions, statements, methods, IntelliJ code review, and hands-on coding exercises:

Introduction to the fundamentals of Java workflow

Exploring Java keywords and understanding expressions

Mastering Java statements, whitespace, and code organization

Working with code blocks and the if-then-else statement

Practical if-then-else challenge for Java flow control

Deep overview of methods in Java for reusable code

Additional Java method techniques

Comprehensive recap of Java methods

Hands-on Java method challenge

Comparing and reviewing code in IntelliJ

Introduction to Java coding exercises

Delving into method overloading in Java

Practical method overloading challenge

Seconds-and-minutes challenge for time-based calculations

Bonus challenge solution and key insights

Coding Exercises

The course also includes hands-on exercises covering:

Positive, Negative, or Zero assessment

Speed converter

MegaBytes converter

Barking Dog program

Leap Year calculator

Decimal comparator

Equal Sum checker

Teen number checker

Area calculator for circles and rectangles

Minutes-to-years-and-days calculator

Equality printer

Playing Cat logic program

Section 6 — Mastering Conditional Logic, Loops, and Interactive Java Applications

This section focuses on program flow, switch statements, loops, variable scope, classes, objects, and practical problem-solving:

Introduction to the foundations of program flow in Java

Exploring traditional and enhanced switch statements

Advanced switch statement features

Traditional switch statement challenge and practical exercises

Switch expressions with a hands-on coding challenge

Mastering the for statement for repetitive task automation

Comprehensive for loop challenge to strengthen iteration skills

Sum 3 and 5 challenge with IntelliJ debugger insights

for loop recap and key iteration takeaways

while and do-while statements for conditional looping

Practical while loop exercises and challenges

Digit sum challenge and further looping techniques

Revisiting while and do-while loops

Exploring local variables and scope in Java blocks

Understanding classes, objects, and static versus instance members

Section 6 Coding Exercises

The section also contains additional hands-on programming exercises:

Determining word representation of numbers

Computing month length with leap-year consideration

Summing odd numbers in a specified range

Identifying palindromic numbers

Summing the first and last digits of an integer

Calculating the sum of all even digits in an integer

Checking for a shared digit between two numbers

Evaluating the last digit for multiple integer comparisons

Listing all factors of a given number

Deriving the Greatest Common Divisor (GCD) efficiently

Confirming perfect numbers through the sum of proper divisors

Converting digits into words and handling edge cases

Managing flour pack requirements with limited bucket sizes

Identifying the largest prime factor of a number

Constructing a diagonal star pattern with loops

Hands-on Practice

The course concepts are reinforced through source code organized into:

Topic examples — focused programs for individual Java concepts

Exercises — numbered programming exercises for repetition and problem-solving

Challenges — focused coding problems that apply multiple concepts together

📁 Project Structure

Java-Basics-Learning/ │ ├── Challenges/ │ └── src/ │ ├── ForLoop.java │ ├── Methods.java │ ├── One.java │ ├── SwitchEnhanced.java │ ├── SwitchTraditional.java │ └── WhileLoop.java │ ├── Exercises/ │ └── src/ │ ├── One.java │ ├── Three.java │ ├── Four.java │ ├── Five.java │ ├── Six.java │ ├── Seven.java │ ├── Eight.java │ ├── Nine.java │ ├── Ten.java │ ├── Eleven.java │ ├── Twelve.java │ ├── Thirteen.java │ ├── Fourteen.java │ ├── Fifteen.java │ ├── Sixteen.java │ ├── Seventeen.java │ ├── Eighteen.java │ ├── Nineteen.java │ ├── Twenty.java │ ├── TwentyFive.java │ ├── TwentyEight.java │ └── ... │ ├── ForLoop/ ├── HelloWorld/ ├── KeywordsAndExpressions/ ├── Method/ ├── Method Overloading/ ├── Switch/ ├── While and do while/ │ ├── Java-Basics-Learning.iml └── README.md

The Exercises folder contains additional numbered Java programs beyond the files visible in the current project structure.

📌 Course Progress

The repository is being built alongside a structured Java course.

Section

Focus

Progress

1

Getting Started with Java Programming

Completed

2

Java Development Environment Setup

Completed

3

First Steps in Java Programming

Completed

4

Transitioning from JShell to IntelliJ IDEA

Completed

5

Mastering Java Expressions, Statements, Code Blocks, and Method Overloading

Completed

6

Mastering Conditional Logic, Loops, and Interactive Java Applications

In Progress

The numbered source files and topic folders are used to practice the concepts covered throughout the course.

🧠 Learning Approach

The repository follows a simple learn → practice → challenge approach.

  1. Learn the concept

Topic-based folders contain small Java programs focused on a specific language feature.

For example:

HelloWorld/ KeywordsAndExpressions/ Method/ Method Overloading/ ForLoop/ Switch/ While and do while/

  1. Practice

The Exercises directory contains individual Java programs used to practice problem-solving and reinforce Java fundamentals.

  1. Challenge yourself

The Challenges directory contains additional programs that combine Java concepts into small coding problems.

☕ Technologies

Language: Java

IDE: IntelliJ IDEA

Build: Simple Java source files

Version Control: Git

⚙️ Prerequisites

Before running the programs, install:

Java Development Kit (JDK 17 or compatible LTS version)

IntelliJ IDEA or another Java-compatible IDE

Git, if you want to clone the repository

Verify Java is installed:

java -version

Verify the Java compiler:

javac -version

🚀 Getting Started

Clone the repository

git clone <YOUR_GITHUB_REPOSITORY_URL>

Move into the project:

cd Java-Basics-Learning

Open the project in IntelliJ IDEA.

▶️ Running a Java Program

Each Java source file can be executed independently when it contains a main method.

For example:

public class HelloWorld {

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

}

Using IntelliJ IDEA

Open the project in IntelliJ IDEA.

Navigate to the required .java file.

Open the file.

Click the green Run ▶ button next to the main method.

View the output in the Run window.

Using the command line

Compile a Java file:

javac HelloWorld.java

Run the compiled class:

java HelloWorld

🔄 Example: Loops

The repository contains examples for different types of loops.

For loop

for (int i = 1; i <= 10; i++) { System.out.println(i); }

While loop

int i = 1;

while (i <= 10) { System.out.println(i); i++; }

Do-while loop

int i = 1;

do { System.out.println(i); i++; } while (i <= 10);

🔀 Example: Switch

The project also contains both traditional and enhanced switch examples.

Traditional switch

switch (day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; default: System.out.println("Invalid day"); }

Enhanced switch

Modern Java allows a more concise syntax:

String result = switch (day) { case 1 -> "Monday"; case 2 -> "Tuesday"; default -> "Invalid day"; };

🧩 Methods

Methods are used throughout the project to practice reusable blocks of Java code.

Basic example:

public static void greet() { System.out.println("Hello!"); }

A method can also accept parameters and return a value:

public static int add(int a, int b) { return a + b; }

🔁 Method Overloading

The repository also includes examples of method overloading, where multiple methods have the same name but different parameter lists.

public static int add(int a, int b) { return a + b; }

public static int add(int a, int b, int c) { return a + b + c; }

📝 Exercises

The Exercises folder is intended for repeated problem-solving practice.

The current project includes numbered programs such as:

One.java

Three.java

Four.java

Five.java

Six.java

Seven.java

Eight.java

Nine.java

Ten.java

Eleven.java

Twelve.java

Thirteen.java

Fourteen.java

Fifteen.java

Sixteen.java

Seventeen.java

Eighteen.java

Nineteen.java

Twenty.java

TwentyFive.java

TwentyEight.java

Additional exercises can be added as the learning journey progresses.

🏆 Challenges

The Challenges folder contains focused programs for applying concepts rather than only studying syntax.

Current challenge examples include:

ForLoop.java

Methods.java

SwitchTraditional.java

SwitchEnhanced.java

WhileLoop.java

These programs can be revisited and improved as Java knowledge grows.

🎯 Learning Goals

The main goals of this repository are to:

Set up a complete Java 17 development environment

Understand Java syntax and program structure

Work with variables, keywords, and primitive data types

Understand integer and floating-point ranges and precision

Practice type casting and wrapper classes

Work with char, boolean, and String

Understand operators, operands, and expressions

Use abbreviated assignment operators

Work with loops and conditional logic

Understand methods and method overloading

Practice traditional and modern switch syntax

Transition from JShell to IntelliJ IDEA

Build and understand IntelliJ project structure

Practice conditional logic using if, else, &&, ||, and ternary operators

Understand operator precedence and expression evaluation

Write reusable methods and understand method overloading

Practice time, number, comparison, and conditional programming problems

Work with traditional and enhanced switch statements

Practice for, while, and do-while loops

Understand local variable scope and block scope

Understand classes, objects, static members, and instance members

Solve number theory and loop-based programming problems

Improve problem-solving skills through exercises and challenges

Build consistency through hands-on coding

Prepare for more advanced Java and backend development topics

📈 Future Topics

As the learning journey continues, this repository can be expanded with:

Arrays

Strings

Object-Oriented Programming

Classes and Objects

Constructors

Inheritance

Polymorphism

Encapsulation

Interfaces

Abstract Classes

Exception Handling

Collections

Generics

File Handling

Streams

Lambda Expressions

Functional Interfaces

Multithreading

JDBC

Unit Testing

🤝 Contributing

This is primarily a personal Java learning repository, but suggestions and improvements are welcome.

If you find an issue or have a better approach to a problem:

Fork the repository.

Create a new branch.

Make your changes.

Commit your changes.

Open a pull request.

📌 Note

This repository is intentionally kept simple. The purpose is not to build a production application, but to document the progression from Java fundamentals to more advanced concepts through hands-on coding.

⭐ If this repository helps you learn Java, feel free to star it and use it as a reference for your own learning journey.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages