A
A
Alexander2015-05-10 06:09:46
Java
Alexander, 2015-05-10 06:09:46

Is it possible to define comparison operators in Java?

I can't find any information on how to define comparison operators. Isn't it possible? O_O

public MyClass() {
  int value = 0;
  public MyClass(int i) {
    this.value = i;
  }
}

MyClass a = MyClass(1);
MyClass b = MyClass(3);

if(a > b) {
// ...
}

Is it really necessary to create comparison functions for these purposes? 0_o

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-05-10
@wxmaper

www.onjava.com/pub/a/onjava/2003/03/12/java_comp.h...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question