HOME HTML EDITOR C JAVA PHP

Java Reference

The Java Reference section provides a quick and structured overview of important Java concepts, syntax, keywords, classes, and commonly used methods. It is designed to help students revise topics quickly and find definitions or examples without reading long explanations.

This reference guide is especially useful for exam preparation, interviews, and last-minute revision.

1. Java Basic Syntax

Every Java program starts with a class and a main method.

public class Main {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}

2. Java Data Types

Java supports two types of data types:

int age = 20;
double price = 99.99;
char grade = 'A';
boolean isPassed = true;

3. Java Operators

4. Java Control Statements

Control statements are used to control the flow of execution.

for(int i = 1; i <= 5; i++){
  System.out.println(i);
}

5. Java OOP Concepts

class Person {
  String name;
  void display() {
    System.out.println(name);
  }
}

6. Java Arrays

Arrays are used to store multiple values of the same data type.

int[] numbers = {1, 2, 3, 4};
System.out.println(numbers[0]);

7. Java Strings

The String class is used to handle text in Java.

String text = "Java";
System.out.println(text.length());
System.out.println(text.toUpperCase());

8. Java Exception Handling

Exception handling prevents runtime errors from crashing the program.

try {
  int result = 10 / 0;
} catch (ArithmeticException e) {
  System.out.println("Error occurred");
}

9. Java Collections

The Java Collections Framework provides classes like ArrayList, HashSet, and HashMap to store and manipulate groups of objects.

import java.util.ArrayList;

ArrayList<String> list = new ArrayList<>();
list.add("Java");
list.add("Python");
System.out.println(list);

10. Java Keywords (Commonly Used)

Why Java Reference is Important?

Helpful Tip: Keep practicing examples from each section. Java Reference is best used along with hands-on coding practice.