Java Basics Cheat Sheet: Your Quick Reference Guide
2 min readOct 25, 2023
Java is a versatile and widely-used programming language known for its platform-independence, strong community support, and vast ecosystem of libraries and frameworks. Whether you’re a beginner getting started with Java or an experienced developer looking for a quick reference, this Java Basics Cheat Sheet has you covered.
Introduction
Java is a high-level, object-oriented programming language. It’s known for its portability and strong support for building scalable and reliable applications. This cheat sheet covers fundamental Java concepts and syntax.
Hello World
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Variables and Data Types
Common Data Types
int
: Integer (e.g., 42)double
: Double-precision floating-point (e.g., 3.14)boolean
: Boolean (true or false)char
: Character (e.g., 'A')String
: Text (e.g., "Hello")
Variable Declaration
int age = 25;
double price = 9.99;
boolean isJavaFun = true;
char grade = 'A';
String greeting = "Hello, World!";
Operators
- Arithmetic:
+
,-
,*
,/
,%
- Comparison:
==
,!=
,<
,>
…