<code>public class Pair<T> {
private T first;
private T second;
public Pair(){
this(null, null);
}
public Pair(T first, T second){
this.first = first;
this.second = second;
}
public T getFirst(){
return this.first;
}
public T getSecond(){
return this.second;
}
public void setFirst(T first){
this.first = first;
}
public void setSecond(T second){
this.second = second;
}
}
class DateInterval extends Pair<LocalDate>{
public LocalDate getSecond(LocalDate second){
return (LocalDate)super.getSecond();
}
...
}
public static void main(String... args){
var interval = new DateInterval();
Pair<LocalDate> pair = interval;
LocalDate res = pair.getSecond();
}
</code>
<code>public class Pair<T> {
private T first;
private T second;
public Pair(){
this(null, null);
}
public Pair(T first, T second){
this.first = first;
this.second = second;
}
public T getFirst(){
return this.first;
}
public T getSecond(){
return this.second;
}
public void setFirst(T first){
this.first = first;
}
public void setSecond(T second){
this.second = second;
}
}
class DateInterval extends Pair<LocalDate>{
public LocalDate getSecond(LocalDate second){
return (LocalDate)super.getSecond();
}
...
}
public static void main(String... args){
var interval = new DateInterval();
Pair<LocalDate> pair = interval;
LocalDate res = pair.getSecond();
}
</code>
public class Pair<T> {
private T first;
private T second;
public Pair(){
this(null, null);
}
public Pair(T first, T second){
this.first = first;
this.second = second;
}
public T getFirst(){
return this.first;
}
public T getSecond(){
return this.second;
}
public void setFirst(T first){
this.first = first;
}
public void setSecond(T second){
this.second = second;
}
}
class DateInterval extends Pair<LocalDate>{
public LocalDate getSecond(LocalDate second){
return (LocalDate)super.getSecond();
}
...
}
public static void main(String... args){
var interval = new DateInterval();
Pair<LocalDate> pair = interval;
LocalDate res = pair.getSecond();
}
In class DateInterval, wether generate bridge method Object getSecond()
like:
<code>public Object getSecond() {
return this.getSecond();
}
</code>
<code>public Object getSecond() {
return this.getSecond();
}
</code>
public Object getSecond() {
return this.getSecond();
}
or not? I get answer ‘yes’ from books named Core Java VolumeI. But i have learnt that, function signature in java only include function name and parameters list, with no return type, so i think function getSecond
has been overwrite correctly, there is no need to generate bridge method above. So what is the truth?