Hi! My question is: what is wrong with this conversion?
public int getTheNumber(int[] factors) {
ArrayList<Integer> f = new ArrayList(Arrays.asList(factors));
Collections.sort(f);
return f.get(0)*f.get(f.size()-1);
}
I made this after reading solution found in http://stackoverflow.com/questions/157944/how-to-create-arraylist-arraylistt-from-array-t-in-java
The second line (sorting) in getTheNumber(...) causes exception (Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to java.lang.Comparable).
What is wrong here? I do realize that sorting could be done with Arrays.sort(), I'm just curious about this one.
Thanks :)