๐งฐ Java Basics to Intermediate โ A Comprehensive Guide for 2025
๐งฒ Introduction โ Why Learn Java From Basics to Intermediate?
Java remains one of the most powerful, secure, and widely-used programming languages. Whether youโre a beginner or looking to level up your skills, mastering Java from the ground up opens doors to web, mobile, and enterprise development.
๐ฏ In this guide, youโll learn:
- How to get started with Java setup and syntax
- Java fundamentals like variables, data types, operators
- Control flow, loops, strings, and arrays
- Intermediate-level concepts like type casting, math operations, and more
๐ Topics Covered
| ๐ข Topic | ๐ Description |
|---|---|
| Java HOME | Entry point for Java documentation and reference |
| Java Introduction | Background, features, and use-cases |
| Java Syntax | Structure, naming rules, case sensitivity |
| Java Get Started | JDK installation and IDE setup |
| Java Output | Printing with System.out.println() |
| Java Comments | Single-line and multi-line comments |
| Java Variables | Declaring and initializing variables |
| Java Data Types | Primitive types like int, char, boolean |
| Java Type Casting | Converting data types (implicit & explicit) |
| Java Operators | Arithmetic, logical, comparison, assignment |
| Java Strings | String creation, methods, concatenation |
| Java Math | Math class functions (abs, max, random) |
| Java Booleans | Working with true/false conditions |
| Java IfโฆElse | Conditional execution logic |
| Java Switch | Multi-branch control structure |
| Java While Loop | Looping with unknown iterations |
| Java For Loop | Looping with known range or counter |
| Java Break/Continue | Jumping out or skipping loop iterations |
| Java Arrays | Storing and accessing multiple values |
๐ Java HOME โ Your Launchpad
The Java HOME is typically the starting documentation page or landing section where you access everything from setup to advanced tutorials.
- Use it as a reference hub for Java features and updates.
- Most IDEs and Java distributions come with links to this.
๐ Java Introduction โ The Language at a Glance
- Developed by Sun Microsystems in 1995
- Runs on the Java Virtual Machine (JVM)
- Follows OOP principles
- Write once, run anywhere (WORA)
๐งพ Java Syntax โ Structure & Rules
Java is case-sensitive and uses a strict syntax for clarity and consistency.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
- Semicolons (
;) end statements - Curly braces
{}define blocks - Method names use camelCase
๐ Java Get Started โ Setup Steps
- Download and install the JDK
- Configure
JAVA_HOMEand system PATH - Use a Java IDE like IntelliJ IDEA, Eclipse, or NetBeans
- Create your first project and write the main method
๐จ๏ธ Java Output โ Printing to Console
Use the System.out.println() method:
System.out.println("Welcome to Java!");
๐ฌ Java Comments โ Code Documentation
- Single-line:
// This is a comment - Multi-line:
/* This is a multi-line comment */
๐งฎ Java Variables โ Data Storage
int age = 25;
String name = "Alice";
Variables store data. You must define the type before using them.
๐ข Java Data Types โ Know Your Primitives
| Type | Example | Description |
|---|---|---|
int | 10 | Whole numbers |
double | 12.5 | Decimal numbers |
char | ‘A’ | Single characters |
boolean | true | Logical values |
๐ Java Type Casting โ Conversions
Implicit (widening):
int x = 10;
double y = x;
Explicit (narrowing):
double a = 10.5;
int b = (int) a;
โ Java Operators โ Perform Operations
| Operator Type | Symbols |
|---|---|
| Arithmetic | + - * / % |
| Comparison | == != > < >= <= |
| Logical | `&& |
| Assignment | = += -= *= |
๐ค Java Strings โ Working with Text
String greeting = "Hello";
String name = "Java";
System.out.println(greeting + " " + name);
Use .length(), .toUpperCase(), .equals(), etc.
๐ Java Math โ Numbers Made Easy
System.out.println(Math.max(5, 10));
System.out.println(Math.random());
Useful methods:
Math.sqrt(x)Math.pow(x, y)Math.abs(x)
๐ง Java Booleans โ True/False Logic
boolean isJavaFun = true;
System.out.println(isJavaFun);
Used in control flow (if, loops, etc.)
๐งฎ Java IfโฆElse โ Decision Making
if (age > 18) {
System.out.println("Adult");
} else {
System.out.println("Minor");
}
๐ Java Switch โ Multiple Cases
int day = 2;
switch (day) {
case 1: System.out.println("Mon"); break;
case 2: System.out.println("Tue"); break;
default: System.out.println("Other");
}
๐ Java While Loop โ Conditional Loop
int i = 0;
while (i < 5) {
System.out.println(i);
i++;
}
๐ Java For Loop โ Counted Loop
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
โน๏ธ Java Break/Continue โ Control Loop Flow
for (int i = 0; i < 10; i++) {
if (i == 3) continue;
if (i == 7) break;
System.out.println(i);
}
breakexits the loopcontinueskips current iteration
๐ Java Arrays โ Store Multiple Values
String[] cars = {"Volvo", "BMW", "Tesla"};
System.out.println(cars[0]);
- Arrays are fixed-size
- Access via index (
array[index])
๐ Summary โ Recap & Next Steps
๐ฏ By now, youโve learned the core to intermediate fundamentals of Java. This is the most important layer before diving into advanced concepts like OOP, file I/O, and frameworks.
๐ Key Takeaways:
- Setup your environment using JDK + IDE
- Master Java syntax, control flow, and loops
- Work with variables, strings, arrays, and booleans
- Understand type casting, operators, and output
โ๏ธ Whatโs Next?
Start practicing small Java programs:
- Build a calculator ๐งฎ
- Create a quiz app โ
- Develop a contact manager ๐
โ Frequently Asked Questions (FAQs)
โ Do I need to install Java to run Java code?
โ
Yes, you need to install the JDK (Java Development Kit) to compile and run Java programs locally.
โ What is the difference between int and Integer in Java?
โ
int is a primitive type; Integer is an object wrapper class in Java that supports null values and utilities.
โ Can I use Java for web development?
โ
Yes! With frameworks like Spring and JSP, Java is widely used in backend web development.
โ How are strings stored in Java?
โ
Strings in Java are objects of the String class and are immutable. They are stored in the String pool to optimize memory.
โ Is Java good for competitive programming?
โ
Java is fast, reliable, and has rich libraries โ great for algorithms and data structure problems in coding competitions.
