I uninstalled jdk1.3 and then rebooted and then reinstalled
jdk1.3 and I still get this classpath error! In the past
an uninstall and reinstall would fix all classpath problems
for me!
Error message is :
Exception in
thread "main" java.lang.NoSuchMethodError: main
PS: The whole block of code from here to the end compiles
as one file "BubbleSortArray" and it does compile but does
not run!
http://java.sun.com/j2se/1.3/docs/api/java/lang/NoSuchMethodException.html Code below:
/**********************************************************
Bubble sort: The bubble sort is very slow but it is the most simple algorithm thus
bubble sort will be the first one we talk about!
If one could only see 2 famous/infamous mountains at the same time, and thus
could compare them , Thus bubble sort can only sort 2 items at a time and swaps
them and then more over one slot and compare again. This is why it is called bubble
sort because the items bubble up and keeps on making passes up the array until
the array is sorted.
*************************************************************/
// BubbleSortArray.java
class BubbleSortArray {
private double[] b; // reference to array
private int numberOfElements; // number of items
public BubbleSortArray( int max) // constructor
{
b= new double[max]; // creating array
numberOfElements = 0; // no items in slots
}
public void insert( double value) // items in slot
{
b[numberOfElements] = value; // insert and increment
numberOfElements++;
}
public void display() // display contents of all slots of array
{
for( int j=0; j<numberOfElements; j++) // this displays all elements<br /> System.out.print(b[j] + " ");<br /> System.out.println(" " );<br /> }<br /> public void BubbleSort()<br /> {<br /> int out, in;<br /> for( out = numberOfElements-1; out>1; out--)
for(in =0; in<out; in++) // outer loop backward<br /> if( b[in] > b[in+1]) // inner loop forward
swap(in, in+1); // swap them
}
protected void swap( int one, int two)
{
double temp = b[one];
b[one] = b[two];
b[two] = temp;
}
}
class BubbleSortExample {
public static void main(
String argv[] )
{
int maxSize = 25; // array size : Note always make arrays bigger then you need
BubbleSortArray arr; // reference to array BubbleSortArray
arr = new BubbleSortArray(maxSize); // creates array
/// insert items here
arr.insert( 28250 );// K2 8611 meters
arr.insert( 22835 );// Aconcagua
arr.insert( 16067 );// VINSON MASSIF
arr.insert( 14870 );// MatterHorn
arr.insert( 29028 );//MT.Everest
arr.insert( 9836 );//Dolomites
arr.insert( 28208 );//KANGCHENJUNGA
arr.insert( 17887 );//POPOCATEPETL
arr.insert( 14225 );//longs peak
arr.insert( 5267 );//Katahdin
arr.insert( 20320 ); //Mt. McKinley
arr.display(); // display items
arr.BubbleSort(); // sort them
arr.display(); // and display the sorted array
} // end of the main method/function
} // End of class BubbleSortExample