강의

멘토링

커뮤니티

Inflearn Community Q&A

spacedust's profile image
spacedust

asked

Data Structure Learning with Java

추상클래스와인터페이스 관련강의

Written on

·

213

0

제3-4장 : 추상클래스와 인터페이스 강의에서 4번강의에서 Event클래스에서 

public abstract class Event implements Comparable{
public String title;

public Event(String title) {
this.title = title;
}

public void print(){
System.out.println("title = " + title);
}

public abstract MyDate getRepresentativeDate();
 @Override
public int
compareTo(Object o) {
MyDate mine = getRepresentativeDate()
;
MyDate yours = ((Event)o).getRepresentativeDate()

return mine.compareTo(yours);
}
}
이렇게 작성을 하려면 MyDate클래스에 compareTo메서드가 있어야하는데 교수님께서 강의에서 말씀하시길 MyDate클래스에 compareTo() 메서드 이름이 달라도
상관없다고 말씀하셨는데 그러면 MyDate클래스에 Comparable인터페이스를 implements를 하여 오버라이딩을 해야하지않나요??? 강의에서 보면 교수님이 직접
만드신 compareTo()메서드만 있어서 이 부분이 이해가 가지 않습니다.

java

Answer

This question is waiting for answers
Be the first to answer!
spacedust's profile image
spacedust

asked

Ask a question