cheat sheet for java
Here is a concise cheat sheet for Java programming covering key concepts useful for beginners
and developers:
Java Cheat Sheet
Basics
Hello World
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Compile: javac HelloWorld.java
Run: java HelloWorld [1]
Data Types
int — Integer numbers
float — Floating-point numbers
char — Single character
boolean — true/false
String — Sequence of characters [2]
Variables
Declaration and assignment
int age = 25;
String name = "Alice"; [2]
Operators
Arithmetic: + - * / %
Comparison: == != > < >= <=
Logical: && || ! [2]
Control Flow
If condition
if(age > 18) {
System.out.println("Adult");
} else {
System.out.println("Minor");
}
Switch case
switch(day) {
case 1: System.out.println("Monday"); break;
default: System.out.println("Other day");
}
Loops: for, while, do-while [3]
Methods
Define and call
public int add(int a, int b) {
return a + b;
}
Call: int sum = add(5, 3); [2]
Object-Oriented Concepts
Class and Object
public class Car {
String color;
void drive() {
System.out.println("Driving");
}
}
Car myCar = new Car();
myCar.drive();
Inheritance, Polymorphism, Encapsulation [3]
Exception Handling
Try-catch block
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: Division by zero");
}
Common Libraries
java.lang – Basic classes (String, Math)
java.util – Collections, Date/Time, Scanner
This cheat sheet summarizes the key Java programming essentials for quick reference and
study. [1] [3] [2]
⁂
1. https://quickref.me/java.html
2. https://www.geeksforgeeks.org/java/java-cheat-sheet/
3. https://introcs.cs.princeton.edu/11cheatsheet
4. https://www.codewithharry.com/blogpost/java-cheatsheet
5. https://github.com/in28minutes/java-cheat-sheet
6. https://programiz.pro/resources/java-cheat-sheet/
7. https://www.codecademy.com/resources/cheatsheets/language/java
8. https://www.interviewbit.com/java-cheat-sheet/
9. https://www.edureka.co/blog/cheatsheets/java-cheat-sheet/