Results 1 to 5 of 5

Thread: How can I make this unchecked method invocation checked?

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved How can I make this unchecked method invocation checked?

    This is driving me crazy. As it stands below the compiler complains that the method invocation is unchecked. If I add a type parameter getMax(Collection<Num> c) the compiler moans that it canno't find symbol method max(java.util.Collection<Num>).
    Code:
    public static Num getMax(Collection c){
     return Collections.max(c); 
    }
    The method prototype simply suggests that any type can be passed in that extends the type that the Collection is marked to hold.
    Code:
    public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width