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 6892419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:31:59+00:00 2026-05-27T06:31:59+00:00

I try to create a collection. Just a small collection with 3 names and

  • 0

I try to create a collection. Just a small collection with 3 names and i want to sort them by Alphabetically order. and it hits me always this error: Exception in thread “main” java.lang.AbstractMethodError: collection.compareTo(Ljava/lang/Object;)I. in the line: Collections.sort(names); what should i do to overcome my problem?

 public  class collection implements Comparable<collection> {

private String name;

public collection(String name){
    this.name= name;

}

public String getName(){

    return name;

}

public int compareΤο(collection c){
    return this.getName().compareTo(c.getName());

}

}


public class collectionList {

private ArrayList <collection> names;

public collectionList(){
    names = new ArrayList <collection>();
}
public void populate() {
    collection c1 = new collection("Monica Rows");
    names.add(c1);
    collection c2 = new collection("Peter Walker");
    names.add(c2);
    collection c3 = new collection("Jack Miller");
    names.add(c3);


  }

public void sortBy(){
    Collections.sort(names);
}

public String names(){
    String s="";
    for(collection c: names){
        s+=c.getName()+ "\n";
    }

    return s;
}



 }

public class collectionMain {


public static void main(String[] args){
    collectionList c = new collectionList();
    c.populate();
    System.out.println(c.names());

    c.sortBy();
    System.out.println(c.names());
}

}

  • 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-27T06:32:00+00:00Added an answer on May 27, 2026 at 6:32 am

    The name of your compareTo method is using unicode characters. The “T” is unicode 0x03A4 and the “o” is 0x03BF. They should be 0x0054 and 0x006F. You can check your characters using the following link.

    http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%26%23932%3B&mode=char

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

Sidebar

Related Questions

I want my code to automatically try multiple ways to create a database connection.
I want to try create something like Zend's Server Pagecache. What I want to
Im try to create a spinner dynamically on press of a button. this is
I am writing a small silverlight app just to try silverlight. My idea is
I create an IEnumerable object that just contains the nodes I want from an
I just want to know if this is possible to do with fluent nhibernate.
I try create a map for open ~/.vimrc, but open the ~/.vimrc only when
I try to create donate via PayPal button and add custom select with amount.
I try to create styles with first-child and last-child items but I encountered a
I try to create my own linux bash script that calls truecrypt for mounting.

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.