32 bit signed integer
32 bit float (number with decimal point)
64 bit float (number with decimal point)
16 bit signed integer
64 bit signed integer
Character
Boolean value (either true or false)
Addition
Unary positive, makes number positive
Subtraction
Unary negative, makes number negative
Multiplication
Division
Modulo (remainder of division)
Increment then return
int x = 1;
System.out.println(x++);
//Prints 2
Return then increment
int x = 1;
System.out.println(++x);
//Prints 1
Decrement
Equals
a+=b is a=a+b
a-=b is a=a-b
a*=b is a=a*b
a/=b is a=a/b
a%=b is a=a%b
a&=b is a=a&b
a|=b is a=a|b
a^=b is a=a^b
a>>>=b is a=a>>>b
a><<=b is a=a><<b
Is equal to
Is not equal to
Greater than
Less than
Greater than or equal to
Less than or equal to
Checks if an object is a certain type
Bitwise AND
Bitwise OR
Bitwise XOR
Arithmetic shift left (shifts all the bits one space to the left, essentially multiplying it by 2)
Logical shift right (shifts all the bits one space to the right, essentially dividing it by 2)
Bitwise NOT
AND operator
OR operator
NOT operator
Applies method to object
Applies a state to an enum type
Used to separate parameters
Denotes array data type
References a array's index
Defines a list
Denotes parameters of a function
Defines a block
Initialises an array
Used for switch cases
Used for for loops on objects within objects
Denotes a lambda expression
Denotes wrapper type; a generic type defined for a class or function.
ArrayList<int> l;
public static <T> void f(T genericObject) {
Declares a string
Declares a string
Declares a char
Declares end of a line of code
Reference operator; Shorthand form for lambda expressions that automatically takes in an argument to a class or instance function
Varargs; Declares option to either parse multiple parameters or parsing an array
Annotation operator; denotes a method annotation or decorator
Concatenates strings
'These are '+'two strings!'
Used for including a class in another class, creating polymorphism
Used for referencing the class' superclass
Used for including an interface in another interface or in a class, creating polymorphism
Declares an enum; a datatype that denotes a "state" of something
public enum enumName {
code;
}
Used for declaring an interface; like a class but has no variables and methods can be empty
Declares an interface; like a class but has no variables and methods are not defined
public interface interface {
code;
}
Used for declaring an abstract class or method, which is a class or method that is only accessible through its subclasses and is defined in its subclass
Switches logic flow based on an output
switch (expression) {
case x:
code;
break;
case y:
code;
break;
}
Used for declaring doubles (also known as floats, or numbers with decimal place)
Used for declaring booleans
Used for declaring integers
Used for declaring strings
Used for declaring methods that do not depend on the state of the class
Used for declaring loop in a while loop
Throws an exception object
throw new exception();
Used for denoting methods that throw specific errors
Used for declaring characters
Used for declaring that a method does not return a specific value
Used for referring to the original constructor of a class on which a new object is being created
this()
Used for referring to the class object
this.classMethod()
this.classVariable
When used within a constructor method, used for referring to the instance of the class
this.instanceVariable
Used for declaring new objects from a class
Used for declaring private classes or methods, that cannot be interacted with by other classes
Used for declaring public classes or methods, that can be interacted with by other classes
Executes code if condition is true
if (condition) {
code;
}
Loops code while a condition is true
while (condition) {
code;
}
do {
code;
}
while (condition);
Loops code for a set amount iterations or for every object in list
for (initialization; condition; update) {
code;
}
for (type variable:
array) {
code;
}
Attempts to execute code and jumps to the subsequent except on an error
try {
code;
}
try (declaration) {
code;
}
Executes code on failed try statement
catch (Exception exception) {
code
}
Executes code when if or else if isn't executed
else {
code;
}
Used for importing foreign classes for use in code
Used to give a final value at the end of a function or method
Used to tell compiler to end the loop
Used to denote a class with no subclasses or a function that can't be overwritten in a subclass
Declares a class
public class class {
code;
}
Declares an interface
Default case in a switch statement
Executes code after try and catch blocks
finally {
code;
}
Constructor of a class (method to make objects of a class)
Returns Boolean on whether two objects have the same value
boolean object1.equals(object2);
Declares if an object ends in a certain string
boolean object.endsWith("string");
Declares position of string in object
Declares the main function in a class
public static
void
main(String[] args){
code;
}
Includes foreign file's module
import module;
Used to tell compiler the rest of this line is not to be compiled
//This isn't compiled
Opens a multi line comment
/*This isn't compiled
neither is this line*/
Closes a multi line comment
/*This isn't compiled
neither is this line*/
A method that takes another method as parameter and returns a new method
Used to tell compiler to replace the old instance of the function with this one
@override