Introduction, Basic Java


Exercise 2.1 in the book: Learn how to compile a Java program with the javac command and run the compiled program with the java.


Exercise 2.7 in the book. The topic is getting arguments from the command-line.


Exercise 3.6 in the book. The topic of the exercise is Strings in Java.


Exercise 3.10 in the book. The topics are the switch statement and loop structure.


Design a method that finds the largest value in an array of integers. The array is provided as a parameter to the method.

Extra Assignments


Write a sort method that takes as input an unsorted array of integers in the range 0-9998 and prints the integers to screen in decreasing order. As an example on the input 23, 1, 9783, 1, 1, 23 the method prints 9783 23 1. Duplicates are allowed in the input as you can see, however, if a number is in the input several times (1 and 23 in the example) is should only be printed once. The sort method should have the complexity O(n) where n is the size of the input array. Note that the standard sort methods included in the JDK have the complexity O(nlogn). (Hint: boolean array).


Look at the other programs that are included with the J2SE version 1.4.2 SDK (can be found in the /pack/jdk-1.4.2/bin directory).