Loading...
Main Page → Exercises → Java
Click a category below to view its available exercises.
Java (690)
- Programming practice in Java at a CS1 and CS2 (first and second-course) introductory level.
-
algorithms (44)
- These are miscellaneous problems involving various concepts and algorithms. These are intentionally not categorized by concepts (such as array, string, list, tree, recursion, etc.) so that you must consider for yourself the best way to solve the problem. This category might be useful when studying for a coding interview.
- baggageColors
- baggageColors2
- binaryBoarding
- binaryBoarding2
- bootCode
- bootCode2
- checkSum25
- checkSum252
- compressString
- conwayCubes
- dockingMemoryData
- dockingMemoryData2
- gameOfFlights
- gameOfFlights2
- HitCounter
- isPermutation
- joltageAdapters
- joltageAdapters2
- largestNumber
- longestUniqueString
- matchPattern
- memoryNumberGame
- memoryNumberGame2
- minSubrange
- nextPermutation
- passports
- passports2
- rainRisk
- rainRisk2
- shuttleSearch
- shuttleSearch2
- sortThree
- sumCubes
- sumOf2020
- sum3Of2020
- surveys
- surveys2
- threeSum
- ticketValidation
- ticketValidation2
- toboggan
- toboggan2
- validPasswords
- validPasswords2
-
arrays (65)
-
multi-dimensional arrays (14)
- Exercises involving 2D arrays and image pixels.
- array2dMystery
- array2dMystery2
- array2dMystery3
- array2dMystery4
- countIslands
- flatten
- gameOfLife
- isUnique
- kthSmallest
- matrixSum
- spiral
- unflatten
- xRegions
- zeroRowCol
- arrayMystery
- arrayMystery2
- arrayMystery3
- arrayMysteryExam2
- arrayMysteryExam4
- arrayMysteryExam5
- arrayMysteryExam6
- arrayReferenceMystery
- banish
- collapse
- collapsePairs
- computeAverage
- contains
- copyRange
- countDuplicates
- countUnique
- equals
- evenBeforeOdd
- findMedian
- findRange
- firstMissingPositive
- getPercentEven
- hasMirrorTwice
- indexOf
- isMonotonic
- kMostFrequent
- largestRectangleArea
- longestSortedSequence
- maxValue
- mostWater
- mystery1
- mystery2
- nCopies
- numUnique
- productOfOthers
- PromptNumbers
- PromptNumbers2
- referenceMystery1
- referenceMystery2
- referenceMystery3
- referenceMystery4
- referenceMystery5
- removePalindromes
- reverse
- reverseFirstK
- secondIndexOf
- Sieve
- sorted
- split
- squaredArray
- swapAll
- switchPairs
-
-
backtracking (41)
- canBalance
- canInterleave
- canJump
- canMakeSum
- canPack
- combin
- countBinary
- countDecimal
- crack
- decodeMessage
- deleteAndEarn
- diceRolls
- diceSum
- divide
- increasingSubsequences
- isElementSpellable
- isMeasurable
- knapsack
- largestSum
- listTwiddles
- longestCommonSubsequence
- longestRepeatedSubsequence
- makeChange
- maxSum
- numberPuzzle
- partitionable
- permute
- phoneWords
- printAllBinary
- printAllDecimal
- printSquares
- rodCutting
- solve
- solveQueens
- squishWord
- subsets
- threeSum
- travel
- validIpAddresses
- waysToAverage
- waysToClimb
- weave
-
bigoh (11)
-
classes and objects (13)
-
collections (99)
- Using pre-existing collections from the java.util collection framework.
-
ArrayList (39)
- acronymFor
- addStars
- arrayListMystery1
- arrayListMystery2
- arrayListMystery3
- arrayListMystery4
- arrayListMystery5
- arrayListMystery6
- arrayListMystery7
- arrayListMysteryInsert
- arrayListMysteryRemove
- collectionMystery1
- collectionMystery4
- countInRange
- cumulative
- deleteDuplicates
- findKeithNumbers
- Histogram
- indexOfAll
- insertInterval
- intersect
- isKeithNumber
- kCopies
- mean
- mergeIntervals
- mirror
- mystery1
- removeAll
- removeBadPairs
- removeConsecutiveDuplicates
- removeEvenLength
- removeRange
- repeat
- reverse3
- stretch
- summaryRanges
- switchPairs
- twice
- UniqueNames
- WordCount
-
Stack and Queue (16)
-
List (2)
- These problems involve the List interface, which can refer to a linked list or array list.
- removeEvens
- stutter
-
Set (11)
-
Map (31)
- biggestFamily
- byAge
- collectionMystery1
- collectionMystery2
- collectionMystery3
- collectionMystery4
- collectionMystery5
- CountNames
- counts
- FlightPlanner
- friendList
- getMajorityLastName
- hasDuplicateValue
- hasThree
- intersect
- isSubMap
- lastNamesByAge
- leastCommon
- mapMystery
- mapMystery2
- maxOccurrences
- pairFrequencies
- postalService
- rarest
- rarestAge
- reverse
- split
- starters
- teacher
- toMorseCode
- wordChain
-
collection implementation (82)
- Implementing our own collections from scratch.
-
ArrayIntList (5)
- Implementing our own version of Java's ArrayList that stores only integers for simplicity.
- arrayIntListMystery1
- add
- indexOf
- remove
- stutter
-
binary trees (27)
-
hashing (8)
-
linked lists (42)
-
generic (3)
- Linked lists that use generics, AKA type parameterization.
- countDuplicates
- count
- removeAll
- countDuplicates
- deleteBack
- doubleList
- equals
- evenSum
- hasTwoConsecutive
- indexOf
- isSorted
- kthFromLast
- lastIndexOf
- middle
- min
- nodes5
- nodes6
- nodes7
- nodes8
- nodes9
- nodes10
- nodes11
- nodes12
- nodes13
- nodes14
- nodes15
- nodes16
- nodes17
- removeAll
- removeDuplicates
- removeEvens
- removeRange
- reverse
- rotate
- set
- shift
- split
- stutter
- switchPairs
- takeSmallerFrom
- toString
- transferFrom
-
-
console output (20)
-
critters (13)
-
DrawingPanel (10)
- Practice using the DrawingPanel library created by Reges/Stepp.
- Face
- SmileyFace
- PrettyPicture
- circleLoops
- Spiral
- pumpkinPie
- zoomIn
- Circles
- CafeWall
- Projectile2
-
dynamic programming (16)
-
expressions (18)
- digitExpressions
- displacement
- expressionsExam1
- expressionsExam2
- expressionsExam3
- expressionsExam4
- expressionsExam5
- expressionsExam6
- expressionsNumbers1
- expressionsNumbers2
- expressionsNumbers3
- expressionsNumbers4
- expressionsNumbers37
- expressionsStrings1
- expressionsStrings2
- printMaxMin
- timesOperator
- valuesOfABC
- valuesOfIJK
- variableSyntax
-
file IO (28)
- askFileName
- averageValueInFile
- checkDates
- classPresidents
- coinFlip
- coolest
- Election
- flipAndReverseLines
- flipCoins
- flipLines
- frequentFlier
- Hours
- hoursWorked
- inputStats
- leetSpeak
- mostCommon
- negativeSum
- pigLatin2
- pigLatin
- printBox
- printMostCommonName
- removeDuplicatesFromFile
- reverseChunksInFile
- runningSum
- Weather
- WordCountOops
- wordStats
- wordStatsPlus
-
if else (19)
-
inheritance (7)
-
loops (42)
- AsciiFigure
- armstrongNumbers
- BiggestAndSmallest
- bottlesOfRootBeer
- ComputeSumOfDigits
- FibonacciConstant
- FibonacciSequence
- FizzBuzz
- floydsTriangle
- GuessingGame
- Guess2D
- loopMysteryExam1
- loopMysteryExam3
- loopMysteryExam5
- loopMysteryExam10
- loopMysteryPrint1
- loopTable
- nestedStarsOutput
- nthDigit
- numberLoops1
- numberLoops2
- numberLoops3
- numberLoops4constant
- NumberSquare
- OddStuff
- ProcessName
- ProcessName2
- RangeOfNumbers
- SentinelSum
- sequenceOfNumbers
- sequenceOfStars
- sqrt
- starsPrint
- tableOutput
- variableScope
- whileLoopBasics
- RollTwoDice
- Piglet
- Rocket
- Rocket2
- SpaceNeedle
- SpaceNeedle2
- Book
- Book2
-
parameters and return (47)
- averageOf3
- binaryToDecimal
- Birthday
- BMI
- boxOfStars
- circleArea
- coinFlip
- computeDistance
- countDigits
- daysInMonth
- decimalToBinary
- factorCount
- factorial
- fitnessGoal
- getDaysInMonth
- getFirstDigit
- getLastDigit
- Grades
- Hogwarts
- Investment
- isMultiple
- isPrimeNumber
- MysteryGhost
- OneTwoThree
- ParameterMystery1
- ParameterMysteryClaim
- ParameterMysteryExam1
- ParameterMysteryExam2
- ParameterMysteryExam3
- ParameterMysteryExam4
- ParameterMysteryExam5
- ParameterMysteryExam6
- ParameterMysterySection1
- ParameterMysterySection2
- playRoulette
- printPay
- Projectile
- randomExpressions
- randomOver
- randomWalk
- ReturnMystery1
- Roulette
- showTwos
- sumOfDigits
- sumOfRange
- threeConsecutive
- triangle
-
recursion (57)
- collapseSequences
- countToBy
- crawl
- digitsSorted
- digitSum
- editDistance
- escapeMaze
- evenDigits
- factorial
- hanoi
- hashString
- indexOf
- isPalindrome
- isSubsequence
- matchCount
- mergeDigitPairs
- mirrorSequence
- moveToEnd
- mystery1
- nonMatching
- numberSequence
- power
- printBinary
- printRange
- printStars
- recursionMystery1
- recursionMystery1X
- recursionMystery2
- recursionMystery2X
- recursionMystery3
- recursionMystery4
- recursionMystery5
- recursionMystery6
- recursionMystery7
- recursionMystery8
- recursionMystery9
- recursionMystery10
- recursionMystery11
- recursionMystery348
- recursionMystery648
- recursionMysteryComma
- recursionMysteryDivMod
- recursionMysteryMinus
- recursionMysteryPrintDigits
- repeatString
- replaceAll
- reverse
- reverseLines
- sequence
- starString
- stutterStack
- substring
- sumOfSquares
- sumUpTo
- travel
- waysToClimb
- zigzag
-
searching (8)
-
sorting (11)
-
strings (39)
- addBinary
- addCommas
- addNumeric
- CaesarCipher
- canMakePalindrome
- containsTwice
- convertToAltCaps
- countWords
- crazyCaps
- dnaErrors
- dracula
- isAllVowels
- isPalindrome
- isRotation
- isVowel
- justifyText
- marshallMathers
- multiplyNumeric
- nameDiamond
- NameGame
- printBackward
- removeAll
- removeDuplicates
- repeat
- reverse
- reverseChunks
- reverseWordOrder
- romanNumeralToInteger
- rowColumnConvert
- sameDashes
- startEndLetter
- StringOops
- stutter
- swapPairs
- switchPairs
- toNumberWords
- toRomanNumeral
- wordCount
- zigzagConvert
You must log in before you can search for exercises or top users.
Is there a problem? Contact us.