Java
Learn Java by typing real, idiomatic code.
Type through modern Java: classes and interfaces, generics, the Stream API, records, and lambda expressions. Each snippet is idiomatic Java that compiles, and an AI tutor explains every line — how a stream pipeline evaluates lazily, why an interface beats inheritance here — so the verbosity turns into fluency and your typing keeps up.
Progress0 / 732 solved · 0/50 sections
best wpm
0
avg wpm
0
accuracy
0%
runs
0
level
1
rating
1000
Run Java on your machine
1. Install the toolchain
brew install openjdk # or: sudo apt install default-jdk2. Save your code as Hello.java, then compile & run
javac Hello.java && java Helloprogress by section
1Fundamentals0/25start →
Booleans and nullCompact source & instance mainConstants with finalfor loopEnhanced forHello, Javaif / else if / elseNumeric typesString basicsConditional operatorVariableswhile loopArraysbreak and continueMethodsModule import declarationFixed-width integersParse a numberLocal var inferenceFormat numbersMethod overloadingText blocksVarargsSwitch expressionRecords
2Strings In Depth0/18start →
3Values & References0/16start →
AliasingCopy a list== vs equalsImmutable stringsnull and NPEPrimitive arguments are copiedValue vs reference typesfinal variablesUnmodifiable collectionsPass-by-value of a referenceReassigning a parameter is localRecords have value equalityDefensive copyBoxed Integer identityOptional over nullShallow copy shares nesting
4Slices & Arrays0/18Unlock →
5Data structures0/18Unlock →
ArrayList basicsHashMap basicsHashSet dedupImmutable List.ofList operationsIterate a mapArrays and 2D arraysGroup with computeIfAbsentArrayDeque as a queueArrayDeque as a stackSet algebraCount with mergePriorityQueue (min-heap)Sequenced collectionsSequenced mapMax-heap with a comparatorRecords as dataTreeMap keeps order
6Iterators0/28Unlock →
distinctfilterIntStream aggregateslimit & skipmap & collectindex each elementCollectors.joiningmapToObjmin & max by keypeekreduce with an identityreduce without an identityanyMatch / allMatch / findFirstsortedfilter + map in one passflatMapStream.iterateCollectors.partitioningBysummary statisticsCollectors.toMapCollectors.groupingBya custom IterableStream gatherers: fixed windowsStream gatherers: foldStream gatherers: sliding windowmapMultiTeeing collectorStream gatherers: scan
7Traits0/21Unlock →
InterfaceComparableComparatorConversion factoryDefault methodsequals and hashCodeFunctional interfaceStatic interface methodsSupplier for defaultsCustom toStringBuilt-in functional interfacesChained comparatorsMarker interfacesMultiple interfacesFallible conversionGeneric interfaceGeneric method in an interfaceIterableCustom IteratorPrivate interface methodsResolving default clashes
8Generics0/20Unlock →
Type inference with varBounded type parameterGeneric classGeneric interfaceGeneric methodTwo type parametersFallback with a SupplierGeneric over IterableGeneric map over a listMultiple boundsA non-empty wrapperGeneric stackGeneric varargsUpper-bounded wildcardLower-bounded wildcardExplicit type witnessGeneric sealed typeGeneric with a key functionComparable super wildcardRecursive bound
9Lifetimes0/18Unlock →
Object referencesBlock scopeReturning a referencetry/finally cleanupNulling a referenceStatic holds for the programCustom AutoCloseableCapturing a fieldEffectively-final captureA class holding a referenceDeferred creationShadowing in a nested scopetry-with-resourcesCapturing a loop valueResources close in reverseWeakReferenceCleanerWeak reference after GC
10Closures0/20Unlock →
FunctionA lambdaCapturing the environmentConsumer.andThenStatic method referenceSupplierBiFunctionCallbacksComparator from a lambdaA custom functional interfaceConstructor referenceInstance method referenceLambdas drive the streamPredicate combinatorsFunction.andThenFunction.composeCurryingReturning a functionA stateful accumulatorA list of operations
11Pattern Matching0/19Unlock →
Switch on a StringSwitch on an enumPattern matching for instanceofSwitch expressionArrow switch statementSwitch as an expressionBlock arm with yieldBinding used in the conditionThe null patternHandle present or absentType patterns in switchGuarded patternsRecord deconstructionRecord pattern in an ifSealed types in switchGeneric record patternNested record patternsRecursive sum over a treeEvaluate an expression tree
12Error Handling0/21Unlock →
try/catchtry/catch/finallyNumberFormatExceptionCustom messagesFallback on failureMulti-catchrequireNonNullrequireNonNull with messageUnchecked exceptionsChecked exceptionsStop at the first failureCustom checked exceptionCustom unchecked exceptionKeep only successesMatch on the failure kindCatch and rethrowtry-with-resourcesException chainingException carrying dataInspect the causeSuppressed exceptions
13Option & Result0/20Unlock →
14Conversions0/15Unlock →
15Collection Conversions0/19Unlock →
Array to ListKeys to ListList to arrayList to SetMap from entriesSet to sorted ListList to TreeSetValues to Listdistinct in a streamEntries to ListFlatten nested listsFrequency count with mergeList to DequeHashMap to TreeMapUnique, keeping orderFrequency with countinggroupingByInvert a mapCollectors.toMap
16Math0/14Unlock →
17Encoding0/22Unlock →
String to bytesCharacter checks and caseBytes to StringChar to code pointChar digit valueHex encodeBinary, octal, hex stringsBase64 decodeBase64 encodeBig-endian bytesList code pointsHex decodeLittle-endian bytesBytes vs code pointsParse a number in a baseReverse byte orderURL decodeURL encodeLossy UTF-8 decodeCaesar cipherROT13XOR cipher
18Random0/20Unlock →
Coin flipBounded nextIntPick a random elementSeed from the clockRandom double in [0, 1)Random UUIDWeighted true/falseRandom bytesRandom enum valueRandom number in a rangeShuffle a listRandom alphanumeric stringRoll many diceNormal distributionStream of random intsPassword generatorReproducible sequencesSample k without replacementSecureRandomWeighted choice
19Data I/O0/18Unlock →
Parse CSV into rowsTab-separated valuesBuild a CSV stringSelect one columnCSV into a number matrixSplit off the headerWhitespace-separated matrixRead a data fileSerialize records to CSVSkip blanks and commentsPrint an aligned tableWrite CSV to a temp fileWrite a matrix as textAppend a rowStream lines with BufferedReaderParse key=value configRound-trip write then readDrop unparseable rows
20Linear Algebra0/21Unlock →
Matrix shapeScalar multiplyA matrix of zerosElementwise addArgmax of a vectorIdentity matrixOne-hot encodeTraceStack rows (vstack)ReLU and sigmoidApply a function elementwiseColumn meansColumn sumsCosine similarityFlatten to row-majorMatrix times vectorTransposeMatrix multiplyMin-max normalize columnsSoftmaxStandardize columns (z-score)
21Text Processing0/16Unlock →
22Date & Time0/13Unlock →
23Memory0/13Unlock →
24Modules0/20Unlock →
importA static nested classNamespaced constantsAn enum typeFully-qualified nameOne import per lineNested classesNo import aliasThe package declarationPublic vs privateWildcard importA class with methodsStatic importPrivate field, public getterA facade methodAn inner classAn interfacePackage-privateReach a sibling classServiceLoader
25Macros0/20Unlock →
The assert statementMap.of factoryNames from symbolsRecords as codegenVarargs sumAnnotation array elementAnnotation default valueDefine an annotationAnnotation with a valueString.format specifiersformatted and printfGeneric methodRecord with behaviorVarargs maxRead fields genericallyEnumerate methodsRepeatable annotationsInvoke by nameMethodHandleDynamic proxy
26Testing0/20Unlock →
A boolean checkAn equality checkMultiple testsA not-equals checkTesting string outputTesting a truth tableDoc comment plus a testTesting an error caseExpecting an exceptionA shared setup helperAsserting on a ListTesting an object's methodTesting an OptionalTesting a panic pathTesting a return valueSkipping a slow testAsserting the messageComparing floatsTesting a private helperTable-driven tests
27Algorithms0/11Unlock →
28Sorting Algorithms0/14Unlock →
29Expression Parsing0/6Unlock →
30Idioms0/9Unlock →
31OOP & Traits0/12Unlock →
32Trait Objects0/14Unlock →
33Design Patterns0/14Unlock →
34Async0/3Unlock →
35File I/O0/6Unlock →
36Filesystem0/18Unlock →
37Networking0/17Unlock →
Parse the request lineRoute by pathClassify an IP addressA socket addressBind an ephemeral portBuild an HTTP responseRead a line from a streamResolve a hostnameHalf-close a connectionTCP clientRead timeoutUDP send and receiveBuild a datagram packetHTTP/3 clientA thread per connectionTCP echo round-tripHost a web page
38Concurrency0/11Unlock →
39Unsafe & FFI0/14Unlock →
40Commands0/14Unlock →
41Array0/10Unlock →
43String0/10Unlock →
45Interval0/5Unlock →
46Linked List0/6Unlock →
47Tree0/14Unlock →
Maximum Depth of Binary TreeInvert Binary TreeSame TreeLowest Common Ancestor of a BSTBinary Tree Level Order TraversalSubtree of Another TreeImplement Trie (Prefix Tree)Kth Smallest Element in a BSTValidate Binary Search TreeAdd and Search WordConstruct Binary Tree from Preorder and InorderBinary Tree Maximum Path SumSerialize and Deserialize Binary TreeWord Search II