Professional Documents
Culture Documents
import java.util.*;
INPUT
Scanner sc = new Scanner(System.in);
int i = sc.nextInt(); //stops at whitespace
String line = sc.nextLine(); //whole line
System.out.println(“bla”); //stdout
System.err.print(“bla”); //stderr,no newline
MATH
math.sqrt()
math.pow()
math.round()
math.ceil()
math.floor()
Math.max(x,y)
Math.min(x,y)
Math.abs(x); // absolute value
Math.random(); // 0 to 1
int randomNum = (int)(Math.random() * 101); // 0 to 100
RANDOM
Random rand = new Random();
int rand_int1 = rand.nextInt(1000); // random int 0 to 999
double rand_dub1 = rand.nextDouble(1000); // random double 0 to 999
METHODS
static int name(int x, int y) {
return x + y;
}
public static void main(String args[]) {
System.out.println(add(2, 3));
}
ARRAYS
String[] people = new String[3]; // ARRAY WITHOUT CONTENT
String[] people = { "Max", "Anna" };
System.out.println(people[0]);
PRINTING AN ARRAY
for (int i = 0; i < people.length; i++) {
System.out.println(people[i]);
}
CYLCIC
package Drushim;
}
SORT ARRAY
package Drushim;
}
RANDOM D&D AT HOME
package Drushim;
import java.til.*;
}
IDK
package Drushim;
import java.util.*;