I've spent hours look everywhere on the internet, books, java api docs for help, but can't seem to get good explaination. i really need someone to explain it to me. i need to sort an array of objects. I know i have to implement the comparable interface, but can't understand how it works. for anyone who can give me some help, i will give you my first born. this is as far as i got... don't know where to go from here. Thanks in advance
My program consists of two classes. I have an array of objects i want to sort. At runtime it gave me a NullExpection... something. //first class . . . Arrays.sort(myArray); //in main
------------------------------------------------------------ // my second class class myClass implements Comparable . . . public int compareTo(Object obj) { Customer c=(Customer) obj; if(this.c>c.amount) return 1; else if(this.amount<c.amount) return -1; else return 0; } }