Java Programming Basics
1. Introduction
Java is a high-level, object-oriented, platform-independent programming language that runs on the
Java Virtual Machine (JVM).
2. Java Program Structure
A Java program contains a class, a main() method, and statements. Example: public class Main {
public static void main(String[] args) { } }
3. Variables
Variables store data. Example: int age = 20; String name = "Alice";
4. Data Types
Primitive: byte, short, int, long, float, double, char, boolean. Non-primitive: String, Arrays, Classes.
5. Operators
Arithmetic, relational, logical, assignment, bitwise, and ternary operators.
6. Input and Output
Use [Link]() for output and Scanner class for input.
7. Conditional Statements
if, if-else, else-if ladder, and switch are used for decision making.
8. Loops
for, while, and do-while loops are used for repetition.
9. Methods
Methods are reusable blocks of code. Syntax: returnType methodName(parameters).
10. Arrays
Arrays store multiple values of the same data type.
11. Strings
The String class is used to store and manipulate text.
12. Classes and Objects
A class is a blueprint, while an object is an instance of a class.
13. OOP Concepts
Encapsulation, Inheritance, Polymorphism, and Abstraction are the four pillars of OOP.
14. Exception Handling
Use try, catch, finally, throw, and throws to handle runtime errors.
15. Packages
Packages organize related classes and avoid naming conflicts.
16. File Handling
Java provides File, FileReader, FileWriter, BufferedReader, and BufferedWriter for file operations.