======= also the class diagram. <<<<<<< index.html >>>>>>> 1.13 ======= <<<<<<< index.html >>>>>>> 1.14 ======= >>>>>>> 1.15

Sample Java Code

Last changed: Dec 12, 2000, 07:29 PM


Hello.java

    Our first java program printing the proverbial "Hello World"


Loan1.java

    The first version of a code calculating monthly payment for a loan


Loan2.java

    Accomplishes the same task as above but with constructors


Stats.java and TestStats.java

    Use of for loops and if statement, for statement, and the use of String array that is main methods argument


Exp.java

    Example of a method to compute the mathematical function exp(x) (use of while statement)


SimpleSort.java and TestSort.java

    Implementation of insertion sort algorithm; another example of while and for statements in a nested way; check out the flowchart


ArrayDemo.java

    This class demonstrates the difference between assigning and cloning objects and in particular shallow and deep cloning


Employee.java

    This class gives an example of using static variables and methods. The Exp.java program is another example.


Bsearch.java

    This implements the recursive version of binary search algorithm. Compare with the example in figure 7.13 of your text.


SimpleSort.java and TestSort.java (again!)

    I have added the methods kthSmallest and pivot to the SimpleSort class and have slightly changed the main program. Now you can either sort or ask only for the k'th smallest element in the list. A flowchart is included.


Object oriented sort

    This set of programs turn the sort class into an object oriented sorter by decoupling sorting and comparing operations. There is <<<<<<< index.html also the class diagram.


A trivial GUI example and its WindowAdapter

    This simple program shows the very basic thing that you need to do to create a Swing window in Java


ParseString class needed for home work 4

    This class provides a single static method which splits a string into an array of strings


SortGUI.zip

    This is the JBuilder example I worked out in class on 12/12/2000. It is saved in a zip file. Open it up and then open the sortGUI.jpr file in JBuilder and examine it. You still need to clean it up, if you wish to use it for your homework 4 project.