Introduction to Java
🔹 Java Overview
Keypoints:
High-level, multi-platform, object-oriented programming language.
Created by Sun Microsystems in 1995.
Common uses: web apps, mobile apps, enterprise systems, AI, IoT, big data, cloud computing.
Importance:
Write once, run anywhere (WORA).
Widely used with huge community support.
Example:
Apps like Minecraft and Android applications are built with Java.
🔹 Java Runtime Environment (JRE)
Keypoints:
Provides class libraries & resources needed for Java programs to run.
Needed on any device that executes Java apps.
Advantages of Java:
Active community & support.
Many learning resources.
Built-in functions & libraries.
Strong security system.
Platform independence (WORA).
🔹 Java Virtual Machine (JVM)
Keypoints:
Runtime engine that executes Java programs.
Converts Java bytecode → machine language.
Combines compiler + interpreter.
Process:
Source code (.java file).
Compiler → converts to bytecode.
Interpreter (java.exe) → executes line by line on OS.
Importance:
Makes Java cross-platform.
🔹 Java APIs
Keypoints:
APIs = pre-written Java classes & methods.
Add ready-made functionalities (e.g., date, math, text manipulation).
Java has ~50 keywords but thousands of API classes/methods.
Example:
Math.sqrt(25)
→ uses API method to calculate square root.
🔹 Java Skeleton Program
Example Code:
class Skeleton {
public static void main(String[] args){
System.out.println("First Java Application"); //for display
}
}
Key Concepts:
class
= blueprint of objects.Identifiers = names for classes, objects, variables (rules: start with letter/_/$, case-sensitive, no reserved words).
Reserved words = keywords like
class
,public
,static
,void
.
Main Method Breakdown:
public
→ makes method accessible.static
→ can run without creating an object.void
→ no return value.main(String[] args)
→ entry point of program.
Other Notes:
String = sequence of characters.
Array = collection of same data types.
Comments:
// single line
/* multi-line */
🔹 Saving, Compiling & Running Java Programs
Steps:
Write program in text editor (e.g., Notepad).
Save as
.java
file (e.g.,Demo.java
).Open Command Prompt (cmd).
Set JDK path →
set path=%path%;[JDK bin directory]
.Compile →
javac Demo.java
.Run →
java Demo
.
Output Example:
First program in Java
Importance:
Basic workflow every Java programmer must know.