Daniel Kavanaugh wrote: I am struggling with how to sort them particularly (I've tried using arrays.sort() method, but recieve a ClastCastException, stating that the class of my array cannot be cast to java.lang.comparable. I don't get any errors when compiling, so I'm kind of at a loss as to how to attack this problem.
Stevens Miller wrote:Daniel, in about five minutes or so, a very helpful Bartender named "Winston" is going to reformat your post for you, so the code is easier to read.
Check out how he does it as it's a very useful thing to know
Daniel Kavanaugh wrote:How might I create a comparator?
Prasad prap wrote:Have a close look at this example:
Let me know if you have trouble fitting that in your example.
Public class camera implements Comparable
public static Comparator<Camera> ProductNameComparator
= new Comparator<Camera>()
public int compare(Camera camera1, Camera camera2)
String productName1 = camera1.getProductName(productName);
String productName2 = camera2.getProductName(productName);