Currently Integer doesn't implement Comparable. Its on the to do list so hopefully we'll have this soon. In the mean time, use the 2-arg version of Collections.max(Collection, Comparable), and pass it a comparable that can compare integers.
Steve On Thu, Dec 22, 2016 at 5:58 PM, Bryan Buchanan <[email protected]> wrote: > 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. > > -- > You received this message because you are subscribed to the Google Groups > "CodenameOne Discussions" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/ > group/codenameone-discussions. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/codenameone-discussions/17ba622f-463d-4aa7-a61f- > a09aa0b0ef35%40googlegroups.com > <https://groups.google.com/d/msgid/codenameone-discussions/17ba622f-463d-4aa7-a61f-a09aa0b0ef35%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Steve Hannah Software Developer Codename One http://www.codenameone.com -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/CAGOYrKXnSH1nK3Xa_hPR7RZTSNmLjgZqSLwCSVL_OYHc22WWuQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
