Java Handwritten-Style Notes (Day 1: Basics)
✍■ Introduction to Java
- Java is a high-level, object-oriented programming language.
- Write once, run anywhere (WORA) → Java programs can run on any machine with JVM.
- Used in Web apps, Mobile apps (Android), Desktop, Games, Cloud, etc.
✍■ JVM, JRE, JDK
- JVM (Java Virtual Machine): Runs Java bytecode.
- JRE (Java Runtime Environment): Contains JVM + Libraries (to run programs).
- JDK (Java Development Kit): JRE + Development tools (to write programs).
✍■ Structure of a Java Program
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
■ public class → Defines a class (same as filename).
■ main method → Entry point of program.
■ [Link] → Prints output.
✍■ Variables & Data Types
- Variable = container for data.
- Syntax: dataType variableName = value;
Example:
int age = 22;
String name = "Priya";
double pi = 3.14;
Primitive Types → int, float, double, char, boolean
Non-Primitive → String, Arrays, Classes
✍■ Input / Output in Java
- Output: [Link]("Hello");
- Input: Use Scanner class.
Example:
import [Link];
Scanner sc = new Scanner([Link]);
int n = [Link]();
✍■ First Program Flow