optional1 Optional Optionalnull을 안전하게 다루게 해주는 객체객체의 값이 있을 수도 없을 수도 있는 컨테이너 Optional 사용 전 :public class Main { public static void main(String[] args) { Camp camp = new Camp(); Student student = camp.getStudent(); String studentName; if (student != null) { // ⚠️ 가능은하지만 현실적으로 어려움 studentName = student.getName(); } else { studentName = "등록된 학생 없음"; // 기본값 제공 .. 2026. 5. 20. 이전 1 다음