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

  • Home
  • SEARCH
  • 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 7415455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:18:23+00:00 2026-05-29T07:18:23+00:00

I learned about the Comparable interface, for which a class must implement compareTo method.

  • 0

I learned about the Comparable interface, for which a class must implement compareTo method. A project I am using that method as:

public class EmployeeAssignmentTotal implements Comparable<EmployeeAssignmentTotal>, Serializable {

private Employee employee;
private int total;
....
public int compareTo(EmployeeAssignmentTotal other) {
    return new CompareToBuilder()
            .append(employee, other.employee)
            .append(total, other.total)
            .toComparison();
}

What exacly does CompareToBuilder do here? And how is it interacting with the employee and total attributes?


I did read the javadocs, but I cant make head or tail of what they are doing with the constructor and the multiple appends. Does this question indicate unclear intentions and zero research?

  • 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-29T07:18:24+00:00Added an answer on May 29, 2026 at 7:18 am

    This class is meant to assist you in building compareTo()-methods. Imagine you had more than just 2 fields in your class – manually coding your comparison-method could be quite cumbersome.

    CompareToBuilder is doing that for you – each append() method is adding a new comparison, and all comparisons are &&ed.

    So the code you posted runs equals() on the employee object and total.

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

Sidebar

Related Questions

Edit: I recently learned about a project called CommonMark, which correctly identifies and deals
I learned about Lazy class in .Net recently and have been probably over-using it.
I just learned about ngrep , a cool program that lets you easily sniff
So far I have learned about generating thread dump and heap dump using jstack
I recently learned about normalisation in my informatics class and I'm developing a multiplayer
I just learned about list comprehension, which is a great fast way to get
I just learned about the XmlSerializer class in .Net. Before I had always parsed
I learned about location tag that can be used to disable the inheritance for
When I learned about proxy_options I started using it to test all my named
I just learned about Java's Scanner class and now I'm wondering how it compares/competes

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.