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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:12:35+00:00 2026-05-27T07:12:35+00:00

Class Alkio of my previous ! question is chosen to do more methods. Implement

  • 0

Class Alkio of my previous! question is chosen to do more methods.
Implement to the class in addition to the previous ones following
methods:

public boolean suurempiArvo(Alkio verrattava)

and

public int compareTo(Alkio verrattava)

Method suurempiArvo returns true, if the value of the object is
greater than value of verrattava. Method compareTo compares the
values of elements and returns an integer( negative, if the value of
the object is less that value of verrattava, zero, is values are the
same and otherwise positive)

Questions.

Why those methods which are used has just one parameter although methods require values of two elements? If I refer in the methods to verrattava by writing verrattava, how do I refer to object?

  • 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-27T07:12:36+00:00Added an answer on May 27, 2026 at 7:12 am

    When you have a method

    public int compareTo(SomeObject other) {
        // needs implementation
    }
    

    You are comparing other with the current instance. That is to say, the reason why you do not need the second element in the signature is that the second element is already there, it’s the object whose method is being invoked. You compare the members of other with the members of the present instance, basically this, in order to arrive at the proper result.

    public int compareTo(SomeObject other) {
        // assumes member variable foo
        if (this.foo > other.foo) {
            // you finish implementation 
        } 
    }
    

    For clarification, if you were to invoke these methods, it would be something like

    SomeObject first = new SomeObject();
    SomeObject second = new SomeObject();
    int result = first.compareTo(second); 
    

    So you pass the second object into the compareTo method of first. first then compares itself against the second (this vs. other).

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

Sidebar

Related Questions

I have following problem to be solved in java: Implement class Alkio. Test with
class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class
class C { T a; public: C(T a): a(a) {;} }; Is it legal?
class MyClass<T> where T: new() { public Test() { var t = new T();
Class A calls the public method f() in the Constructor. Class B overrides method
class C { public: C(C& c) { i = c.i; j = 100; }
class Test extends JPanel implements MouseListener { private JButton b1, b2, b3, b4; public
class MyClass { public: MyClass() { m_dbLoopStart = 0.0; m_dbLoopStop = 100.0; m_dbLoopStep =
class base{ public $c = 'c'; public $sub = ''; function __construct(){ $this->sub =
class A { public static void main(String[] args) { A a = new A();

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.