Object Class
Object
Object์ ์ฃผ์ ๋ฉ์๋
Equals
hashCode
class Product { String name; int price; @Overriding // ์ค๋ฒ๋ผ์ด๋ฉ์ด๊ธฐ ๋๋ฌธ์ parameter type์ ๋ณ๊ฒฝ ๋ถ๊ฐ public boolean equals(Object obj) { // ๋ณ๋๋ก ํ์ ์ฒดํฌ ์์ธ์ฒ๋ฆฌ ํด์ผ ํจ if (!(obj instanceof Product)) return false; Product other = (Product) obj; return this.name.equals(obj.name) && this.price == obj.price; } @Overriding // equals๊ฐ ๋์ผ ํ๋์์ true์ด๋ฏ๋ก // hashCode๋ ํ๋๊ฐ ๊ฐ์ผ๋ฉด ๋์ผํ ๊ฒฐ๊ณผ๊ฐ ๋์ค๋๋ก ์ค๋ฒ๋ผ์ด๋ฉ public int hashCode() { return Objects.hash(name, price); } }
toString
getClass
clone
Last updated