Your cart is currently empty!
Learn JAVA (Full Tutorial)

Java Introduction
What is Java?
Java is a popular programming language, created in 1995 and owned by Oracle. Over 3 billion devices run Java. It is used for:
-
Mobile apps (especially Android)
-
Desktop apps
-
Web apps and servers
-
Games
-
Database connections
Why Use Java?
-
Platform-independent (Windows, Mac, Linux, Raspberry Pi)
-
Widely used and in high demand
-
Easy to learn and use
-
Free and open-source
-
Secure, fast, and powerful
-
Strong community support
-
Object-oriented: reusable, structured code
-
Close to C++/C#: easy to switch between languages
Installing Java (Windows)
-
Check if Java is installed:
-
If not installed, download it from oracle.com.
-
Set the Path environment variable:
-
Go to Control Panel > System > Advanced System Settings > Environment Variables
-
Edit Path under System variables
-
Add
C:\Program Files\Java\jdk-11.0.1\bin(or your installation path)
-
-
Verify installation:
Your First Java Program
Create Main.java with the following:
Run the program:
Output:
Java Basics
-
Class: Every Java program must have a class. The filename must match the class name.
-
main() method: Entry point of every Java program.
-
Printing to screen:
-
Syntax notes:
-
Java is case-sensitive
-
Each statement ends with a semicolon
; -
Curly braces
{}mark code blocks
-
Java Output / Print
Print Text
Use System.out.println() to print text or values, adding a new line after each call:
Use System.out.print() to print on the same line:
Note: Text must be in double quotes:
Java Comments
-
Single-line:
// This is a comment -
Multi-line:
Java Variables
Variables store data values. Syntax:
Examples:
-
Change value:
-
Final (constant) variable:
-
Multiple variables in one line:
-
Combine text and variables:
-
Combine numbers:
Java Data Types
Primitive types (predefined):
| Type | Size | Description |
|---|---|---|
| byte | 1 B | Whole numbers -128 to 127 |
| short | 2 B | Whole numbers -32,768 to 32,767 |
| int | 4 B | Whole numbers -2B to 2B |
| long | 8 B | Whole numbers, use L suffix |
| float | 4 B | Decimal numbers, use f suffix |
| double | 8 B | Decimal numbers, use d suffix |
| boolean | 1 bit | true / false |
| char | 2 B | Single character, use ' ' |
Examples:
Non-primitive types (reference types, objects):
-
String, Arrays, Classes
Java Type Casting
-
Widening (automatic): smaller → larger type
-
Narrowing (manual): larger → smaller type
Java Strings
-
Store text:
-
Length:
-
Upper / lower case:
-
Find index of a substring:
Java Cheat Sheet
1. Math
2. Booleans
3. Conditionals
4. Loops
5. Arrays
6. Methods
7. Scope
8. Recursion
9. Classes & Objects
10. Attributes
11. Methods in Classes
12. Constructors
13. Modifiers
14. Abstract Classes
15. Encapsulation
16. Inner Classes
Java Abstraction: Abstract Classes & Interfaces
1. Abstract Classes
-
Used to hide details and provide a template.
-
Cannot create objects directly: must be inherited.
-
Can have abstract methods (no body) and regular methods (with body).
Key points:
-
Abstract class = blueprint, cannot instantiate.
-
Subclass must implement all abstract methods.
2. Interfaces
-
Fully abstract: all methods are abstract by default.
-
Attributes are public, static, final by default.
-
Use
implementsto provide method bodies. -
Supports multiple inheritance (a class can implement multiple interfaces).
3. Multiple Interfaces
Notes:
-
Interfaces cannot have constructors.
-
Must override all methods when implementing.
-
Allows security and multiple inheritance.
