[Go to site: main page, start]

0% found this document useful (0 votes)
2 views1 page

Java Reference Guide

This document serves as a quick reference guide for Java programming, covering basic syntax, data types, variables, operators, control flow, classes and objects, inheritance, interfaces, exception handling, arrays, and collections. It includes code snippets to illustrate key concepts such as method definitions, object creation, and control structures. Overall, it provides a concise overview of essential Java programming elements.

Uploaded by

abhi_1991
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java Reference Guide

This document serves as a quick reference guide for Java programming, covering basic syntax, data types, variables, operators, control flow, classes and objects, inheritance, interfaces, exception handling, arrays, and collections. It includes code snippets to illustrate key concepts such as method definitions, object creation, and control structures. Overall, it provides a concise overview of essential Java programming elements.

Uploaded by

abhi_1991
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Quick Reference Guide

Basic Syntax Methods


public class HelloWorld { public static int add(int a, int b) {

public static void main(String[] args) { return a + b;

[Link]("Hello, World!"); }

} Classes & Objects


public class Car {
Primitive Data Types private String color;

byte (8-bit), short (16-bit), int (32-bit), long (64-bit), float (32-bit), public Car(String c) { color = c; }
double (64-bit), boolean, char public String getColor() { return color; }

}
Variables Car myCar = new Car("red");
int age = 25; // Integer

double price = 19.99; // Decimal Inheritance


String name = "John"; // String public class Dog extends Animal {
final int MAX = 100; // Constant @Override

public void sound() { [Link]("Bark");


Operators }

Arithmetic: +, -, *, /, %, ++, -- }

Comparison: ==, !=, >, <, >=, <=


Logical: &&, ||, ! Interface
public interface Drawable {
Control Flow void draw();

if (condition) { } else if { } else { } }

switch(var) { case 1: break; default: } class Circle implements Drawable { }

for (int i=0; i<10; i++) { }

while (condition) { } Exception Handling


do { } while (condition); try {

// code
Arrays } catch (Exception e) {

int[] numbers = {1, 2, 3, 4, 5}; [Link]();

String[] names = new String[3]; } finally {

[Link] // Array size // cleanup

Collections
ArrayList<String> list = new ArrayList<>();

HashMap<String, Integer> map = new HashMap<>();

HashSet<Integer> set = new HashSet<>();

You might also like