contentintech
Languages

Java

Core language, collections and streams for interview-ready Java.

Updated Official documentation ↗

Build and types

javac Main.javaCompile a source file
java MainRun the compiled main class
int count = 3;Declare an integer
String name = "Ada";Declare a string

Collections

List<String> names = new ArrayList<>();Create a mutable list with java.util imports
names.add("Ada");Append an element
Map<String, Integer> scores = new HashMap<>();Create a mutable map
scores.getOrDefault("Ada", 0);Return a default for an absent key

Strings and streams

name.equals("Ada")Compare string content rather than references
names.stream().filter(n -> n.startsWith("A")).toList();Filter to an unmodifiable list on Java 16+
Arrays.sort(values);Sort an array in place
try (var reader = Files.newBufferedReader(path)) { }Close an AutoCloseable resource automatically

Section navigation