๊ฐ์ฒด์ ๋ ฌํ๊ธฐ
-
[์ฝ๋ํธ๋ฆฌ ์กฐ๋ณ๊ณผ์ ] ๊ฐ์ฒดAlgorithm 2024. 8. 4. 21:21
์ฝ๋ฉํ ์คํธ์ ๊ฐ์ด ๋จ์ด์ง๊ธฐ๋ ํ๊ณ , ์ฝํ ๋ฅผ ๊พธ์คํ๊ฒ ๋์ ํ๊ธฐ ์ํด ์ฝ๋ํธ๋ฆฌ ์กฐ๋ณ๊ณผ์ ์ ์ฐธ์ฌํ๊ฒ ๋์๋ค.๋ด๊ฐ ์ค์ค๋ก ๊ณต๋ถํ ๊ฒ์ ์กฐ๋ณ๊ณผ์ ์ ์ฐธ์ฌํ ๊ฒธ, ๊ธฐ๋ก์ ๋จ๊ธฐ๊ธฐ์ํด ์ ๋ฆฌํ๋ ค๊ณ ํ๋ค. ๊ฐ์ฒด ์ ๋ ฌํ๊ธฐpublic class Main { public static class Student { String id; int score; public Student(String id, int score) { this.id = id; this.score = score; } } } ์์์ ๊ฐ์ด Student๋ผ๋ ๊ฐ์ฒด๊ฐ ์๊ณ , Score๋ฅผ ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ์ ํ๊ธฐ ์ํด์ Comparable ์ธํฐํ์ด์ค๊ฐ ํ์ํ๋ค. Compara..