This site contains Java programming and computer science exercises with solutions. To see the solution for an exercises please follow the link to the Javadoc at the and of the exercise's text.

These exercises are designed for an introductional course into computer science with Java as the first programming language.
Some of them have been former used as pratical assignments for my lecture.
They cover basic algorithm design and the fundamental concepts of Java (*without* inheritance, abstract classes, and inner classes).
These exercises are not suitable to learn about Java libraries and APIs like GUI developement with Swing, server side Java or other special Java technologies. To learn about Java technologies, have a look at the Java tutorials at Sun.

You can download all solutions to the Java programming exercises as a compressed zip archive. The source of the Java classes is UTF-8 encoded. Most Java classes can be compiled with Java 1.4, some need Java 1.5 or Java 1.6. Use the newest Java version if possible. You need JUnit to compile the Java test classes.

It is possible to use most of the programming exercises for other programming languages like C# or C++ as well.

The exercises are given in chronological order and by topic. Furthermore, I estimated the degree of difficulty of each Java programming exercise.

- 1, high degree of difficulty, difficult programming exercises
- 2, medium degree of difficulty, suitable for programmers with some experience in Java and computer science
- 3, low degree of difficulty, easy and simple programming exercise, suitable for Java programming beginners

New exercises can be found at the start of the list. I am currently translating my german version of the Java exercises to English.

- Convert hexadecimal numbers to their decimal representation (misc), 2
- Solve English peg solitaire with backtracking (backtracking), 1

- Compare chemical elements with the abstract data type Comparable (interfaces), 2
- Implement the periodic table of the chemical elements by loading the elements values from a file (misc), 2
- Design and implement chemical elements (objects), 2
- Convert a given number of bytes into a representation with metric units (flow control), 3
- Calculate the electrical resistance of a wire (data types and expressions), 3
- Convert 16 bit Unicode into UTF-8 (data types and expressions), 1
- Find the smalles distance between two neighbouring numbers in an array (arrays), 2
- Find the digit sum of a sequence of digits (arrays), 3
- Winning strategy for Roulette (flow control), 2

- Design and implement rational numbers (objects), 2
- Find the day of the week of a given date (flow control), 2
- Generate Sudokus (backtracking), 2
- Design and implement a queue (interfaces), 1
- Implement natural mergesort (sorting), 1
- Implement Newton's method (searching), 2
- Design and implement polynomials (objects), 2
- Implement bottom-up mergesort (sorting), 1-2
- Implement Shell sort (sorting), 1
- Implement Euclids algorithm recursivly (recursion), 2
- Find zeros of continueous functions (searching), 2
- Design and implement a class for wind speed (objects), 2
- Implement a simple calculator (recursion), 1
- Check for anagrams (arrays), 2
- Calculate (german) grades for an examination (flow control), 3
- Sort three numbers (flow control), 3
- Print out the multiplication table for 1 to 10 (flow control), 3
- Give a boolean expression for the definition of a metropolis (data types and expressions), 3

- Solve Sudokus with backtracking (backtracking), 1