Please enable JavaScript.
Coggle requires JavaScript to display documents.
JAVA (String (string concatenation (string + string = new string, string +…
JAVA
String
"..."
string concatenation
string + string = new string
string + number = new string
immutable
= cannot be changed
math funtions
Math.power (base, exponent)
Math.random() * upper bound (exclusive)
Math.round()
class
instance of class
scanner
import java.util.Scanner
Scanner sc = new Scanner(System.in);
random
import java.util.Random
Random rnd = new Random();
methods
void doesn't need to return anything
other types must return stuff
control statements
iterations
for () {}
fixed number of iterations
while () {}
zero or more iterations
do {} while()
one or more iterations
selections
if () {}
switch () {}
arrays
int [] arr = new int [4]
fixed in size
part of java language
import java.util.ArrayList
ArrayList arr = new ArrayList();
flexible in size
elements can be added using arr.add(new element)
elements can be removed with arr.remove(element);
class in Java library
elements can be reached via set/get/add/remove methods
object orientation
different object can communicate
method calling and field access
A must hold reference to B
B must be visible to A
constants
final double pi = 3.1415