Java Cheatsheet

Initialize 2 dim array
int[][] arr = new int[2][2];
print two dim array
java.util.Arrays.deepToString(table)
Read stdin
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
    System.out.println(sc.nextLine());
} 
spaced delimeted string to stream
import java.util.stream.*;
import java.util.regex.*;

Stream stream = Pattern.compile(" ").splitAsStream(scanner.nextLine());

Comments