We take an incremental approach to understanding Java classes. The first step is to view classes as modules and view static methods as functions. After this step, we are able to write many C programs in Java.
+---+
| |
+---+---+
| | |
+---+---+---+
| | | |
+---+---+---+---+
| | | | |
+---+---+---+---+
public class Array {
static int[] copyArray(int[] orig){
// return a copy of orig
}
static void selectionSort(int[] a){
// sort a using the selection sort algorithm
}
static void quickSort(int[] a){
// sort a using the quick sort algorithm
}
static boolean linearSearch(int[] a, int x){
// search x in the array a using the sequential search algorithm
}
static boolean binarySearch(int[] a, int x){
// search x in the array a using the binary search algorithm
// assume a is sorted in acending order
}
}