Show Menu
Cheatography

Java Cheat Sheet (DRAFT) by

A comprehensive cheat sheet for the Java programming language

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Primitive Data Types

Type
Size
Range/­Value
byte
8 bits
-128 .. 127
short
16 bits
-32,768 .. 32,767
int
32 bits
-2,147­,48­3,648 .. 2,147,­483,647
long
64 bits
-9,223­,37­2,0­36,­854­,77­5,808 .. 9,223,­372­,03­6,8­54,­775,807
float
32 bits
3.40282347 x 1038, 1.40239846 x 10-45
double
64 bits
1.7976­931­348­623157 x 10308, 4.9406­564­584­124654 x 10-324
boolean
 
True/False
char
 
Single Characters
String
 
A String of Characters

Escaped Characters

 
Action
\b
Backspace
\n
New Line
\t
Tab
\r
Carriage Return
\f
Form Feed
\"
Double Quote
\\
Back Slash

Key Words

Key Word
Descri­ption
class
Blueprint for an Object
main
public
Available to all Classes
private
Available to this Class only
protected
Available to this Package only
static
void
Does not return any values
final
Always remains the same (constant)
new
Creates a new object
this
 

Arithmetic Operators

Operator
Action
+=
Add
-=
Subtract
*=
Multiply
/=
Divide
%=
Remainder
++
Increment by 1
--
Decrement by 1

Equality and Relational Operators

Operator
Action
>
Greater Than
<
Less Than
==
Equal To
!=
NOT Equal To
>=
Greater Than or Equal To
<=
Less Than or Equal To

Condit­ional Operators

Operator
Action
&&
Returns true if boolean value on the right and left are both true
||
Returns true if either boolean value on the right or left are true
!
Converts the boolean value to its right to its opposite
^
Returns true if there is 1 true and 1 false boolean value on the right or left