Java_Notes_Beginner_Detailed
Java_Notes_Beginner_Detailed
What is Java?
Java is a high-level, object-oriented, and platform-independent programming language. It was developed by Sun
Microsystems in 1995 and is now owned by Oracle. Java applications are compiled into bytecode which runs on the
Java Virtual Machine (JVM), making them portable across platforms.
Example:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Common Mistakes
- Forgetting semicolons
- Mismatched class/file name
- Wrong method signature for main()
Mini Exercise
Create a file HelloWorld.java. Write a program that prints your name. Compile and run it using terminal or IDE.
Definition
Variables are containers for storing data values. Java is statically typed, so you must declare the variable type.
Java Programming Notes - Beginner to Pro Level
Data Types
Primitive types include:
- int: whole numbers
- double: decimals
- char: single characters
- boolean: true/false
- byte, short, long, float for specific use cases
Variable Declaration
Syntax:
int age = 25;
String name = "Alice";
Operators
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <, >=, <=
- Logical: &&, ||, !
Common Mistakes
- Using uninitialized variables
- Type mismatch (e.g., int with string)
Mini Exercise
Declare variables for your name, age, and grade. Print them using System.out.println. Try using arithmetic operators.