Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:36:30+00:00 2026-05-30T20:36:30+00:00

For anyone who might have a question like this, you probably need Collections.sort, not

  • 0

For anyone who might have a question like this, you probably need “Collections.sort”, not “Collection.sort”, the mistake I made below.

I have defined a class defined as

public class Store implements Serializable, Comparable<Store> { ... }

I have a field in another class defined as:

ArrayList<Store> fStores = new ArrayList<Store>();

I want to sort this collection, so in a method I call:

Collection.sort(fStores);

However, I get the following compilation error:

The method sort(ArrayList<Store>) is undefined for the type Collection

ArrayList implements List, and from the documentation:

public static <T extends Comparable<? super T>> void sort(List<T> list)

So, why do I get the error? I have also tried creating my own descendant of Comparator and passing that to the sort method with no luck.

I’m guessing there’s something about “< T extends Comparable< ? super T > >” I’m not understanding… ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:36:31+00:00Added an answer on May 30, 2026 at 8:36 pm

    There are basically 2 things that you need to look at :

    Collections

    From the Collections

    This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, “wrappers”, which return a new collection backed by a specified collection, and a few other odds and ends

    So basically if you have to sort or do any such kind of algorithms use this.

    Next is :->

    Collection

    This is an interface that provides the basis of Java’s collection framework. It does not include Map and Sorted Map. It represents a group of objects known as its elements and has implementations for concrete implementations. You need to think of this when you want to work with ArrayLists and Maps.

    So, bottom line, you have a static algorithm to run which is present in Collections. So, use Collections.sort

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyone who knows this? I have been trying this for the last
EDIT : For anyone who might come across this post with a similar problem,
This question is for anyone who has actually used Amazon EC2. I'm looking into
Important: This question isn't actually really an ASP.NET question. Anyone who knows anything about
This might be an interesting question. I need to test that if I can
Anyone who can answer my question deserves a BIG FAT GOLD MEDAL OF AWESOMENESS!
Anyone who's tried to study mathematics using online resources will have come across these
To anyone who can help, Thanks Okay, so I have a database holding a
(Bonus internets for anyone who can explain how I can do this in both
Is there anyone who have encountered Processing Dirty Regions error in MyEclipse? Actually everytime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.