Unchecked invocation sort

Discussion in 'Java' started by -, Aug 14, 2005.

  1. -

    - Guest

    I have :

    Type safety: Unchecked invocation sort(List, Comparator) of the generic
    method sort(List<T>, Comparator<? super T>) of type Collections


    for this statement:

    Collections.sort(list, createComparator());

    How can I get rid of the warning?
    -, Aug 14, 2005
    #1
    1. Advertising

  2. "-" <> schrieb im Newsbeitrag
    news:...
    >I have :
    >
    > Type safety: Unchecked invocation sort(List, Comparator) of the generic
    > method sort(List<T>, Comparator<? super T>) of type Collections
    >
    >
    > for this statement:
    >
    > Collections.sort(list, createComparator());
    >
    > How can I get rid of the warning?


    list has to be a List on a type T like List<String> and returntype of
    createComparator() has to be a Comparator on the same type T as list (or a
    supertype of T), e.g. Comparator<String>.

    If you ensure this you won't get any classcast exceptions at runtime (and no
    warnings at compiletime of course).

    Regards
    Sebastian
    Sebastian Scheid, Aug 14, 2005
    #2
    1. Advertising

  3. -

    Roedy Green Guest

    Roedy Green, Aug 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ChInKPoInt [No MCSD]

    C# Exception is Unchecked???

    ChInKPoInt [No MCSD], Dec 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    353
    ChInKPoInt [No MCSD]
    Dec 11, 2004
  2. ChInKPoInt [No MCSD]

    C# Exception is Unchecked???

    ChInKPoInt [No MCSD], Dec 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    551
    Richard Blewett [DevelopMentor]
    Dec 11, 2004
  3. Javier
    Replies:
    2
    Views:
    4,106
    Javier
    Dec 12, 2005
  4. RVic
    Replies:
    19
    Views:
    1,389
  5. Navin
    Replies:
    1
    Views:
    690
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page