nus-cs2030 / 2021-s1

27 stars 48 forks source link

Weird behaviour of overloaded method #548

Closed adamozh closed 3 years ago

adamozh commented 3 years ago

Description

Randomly testing, not sure why a.equals(b) would run the method taking in Animal instead of the one that takes in a Dog, like b.equals(b)

Screenshots (if any):

Screenshot 2020-11-29 at 2 17 32 PM

adamozh commented 3 years ago

Closed, found explanation here : https://stackoverflow.com/questions/11625049/covariance-and-overloading-in-java