python - How to overload equality and print in java? -
In Java, how can you increase the surcharge operation and print operation for a class?
Python, you can do I know that you can make a method manually and call it like thanks Used to generate its output you can override And you are right about overriding the method with a warning: If you are overriding the / edit def __eq __ (self): or
def __str __ (self): , but how to do it in Java can be done?
equal or something else, but I want to know whether any real person Which works with
==
== reference will always test for equality.
toString in your class.
equal method, then you should also override the method so that Treat your object with the correct
HashSet and so on. Details about the contract between
Hashod and
equals
public class point {private} Int x; Private int y; Public point (int x, int y) {this.x = x; this. Y = y; } @ Override public string toasting () {return "(" + + "," + y + ")"; } Public static zero main (string [] args) {System.out.println (new point (1, 2)); }}
Comments
Post a Comment