Created
October 1, 2016 15:07
-
-
Save MykolaBova/1ce837557255ea30369698498ab9d942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Equals { | |
public static void main(String[] args) { | |
Car car1 = new Car(12345); | |
Car car2 = new Car(12345); | |
Car car3 = car1; | |
System.out.println(car1.equals(car2)); | |
System.out.println(car1.equals(car3)); | |
} | |
} | |
class Car { | |
protected int speedMax = 100; | |
private long id; | |
public Car(long id) { | |
this.id = id; | |
} | |
public Car() { | |
} | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
public String toString() { | |
return "This is car"; | |
} | |
} | |
class SportCar extends Car { | |
protected int speedMax = 300; | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment