Maybe I'm missing something obvious, but why does this code:
public class FirstCodenameOneLibrary {
/**
* Method javadoc information
*/
public void hello() {
System.out.println("Hello");
}
public void addObjects(Map<Integer, Object> objects) {
int maxObjNumber = Collections.max(objects.keySet());
}
}
give this error:
Compiling 1 source file to /home/bryanb/NetBeansProjects/PDFjet/build/tmp
/home/bryanb/NetBeansProjects/PDFjet/src/com/codename1/hello/FirstCodenameOneLibrary.java:24: error: no suitable method found for max(Set<Integer>)
int maxObjNumber = Collections.max(objects.keySet());
method Collections.<T#1>max(Collection<? extends T#1>) is not applicable
(inferred type does not conform to upper bound(s)
inferred: Integer
upper bound(s): Comparable<? super Integer>,Object)
method Collections.<T#2>max(Collection<? extends T#2>,Comparator<? super T#2>) is not applicable
(cannot infer type-variable(s) T#2
(actual and formal argument lists differ in length))
where T#1,T#2 are type-variables:
T#1 extends Object,Comparable<? super T#1> declared in method <T#1>max(Collection<? extends T#1>)
T#2 extends Object declared in method <T#2>max(Collection<? extends T#2>,Comparator<? super T#2>)
1 error
The Netbeans project is JDK8. The same code compiles fine with JavaSE. The method signatures for Collections.max() are the same for CN1 and regular Java.