Есть класс
public class LuxuryAuto {
private String model;
private int manufactureYear;
private int dollarPrice;
public LuxuryAuto(String model, int manufactureYear, int dollarPrice) {
this.model = model;
this.manufactureYear = manufactureYear;
this.dollarPrice = dollarPrice;
}
}
Мы переопределяем метод equals
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LuxuryAuto that = (LuxuryAuto) o;
if (manufactureYear != that.manufactureYear) return false;
if (dollarPrice != that.dollarPrice) return false;
return model.equals(that.model);
}
Мне здесь непонятен принцип переопределения. Зачем указан параметр (Object o), а не (Object x) например. В инструкции вообще указан (Object obj)
Что такое this, почему мы не прописываем например this.model, а пишем просто this?
Вот эта строка совсем не понятна LuxuryAuto that = (LuxuryAuto) o;