Basic Java

A

Create a "Hello World" programming example. Compile and run the program. The topic is to learn how to compile a Java program with the javac command and run the compiled program with the java.

B

Write a program that prints three arguments taken from the command line.

C

Write a method that takes two string arguments and use the != and the equals method to compare the strings.

D

Create a method that uses a switch statement that prints a message to the screen for each case. Put the switch statement inside a loop statement that tries all the cases. Make two version of the method. One that uses a break for each case and one without breaks. The topics are the switch statement and loop structure.

E

Design a method that finds the largest value in an array of integers. The array is provided as a parameter to the method. Write test data to check that the program is correct.

Extra Assignments

E1

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).

E2

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