본문 바로가기

IT-Language7

JAVA17 - switch - Pattern Matching for switch Java 17에서 패턴 매칭은 switch 문에서 개선되었습니다. 이것은 코드를 더 간결하게 만들고, 더 안전하게 작성하며, 유지 관리하기 쉽게 만듭니다. 예를 들어, 이전 버전의 Java에서는 switch 문으로 instanceof 연산자를 사용하여 형변환 후에 사용할 수 있었지만, Java 17에서는 더 간단한 방법으로 작성할 수 있습니다: [ JAVA7~ ] public String getDayOfWeek(String day) { String dayOfWeek; switch (day) { case "Monday": dayOfWeek = "It's Monday!"; break; case "Tuesday": dayOfWeek = "It's Tuesd.. 2023. 11. 5.
java RuntimeException A RuntimeException is a class in the Java programming language hierarchy used to handle exceptions that can occur at runtime, which are not checked by the compiler. These exceptions are part of the "Unchecked Exception" category, meaning that they do not require explicit handling using try-catch blocks or throws declarations, allowing the program to continue running even when such exceptions occ.. 2023. 11. 5.
Java와 VC++ 동기화 비교 wait, notify(All), synchronized int Count = 0; ////////////// Main Thread ////////////// synchronized(SyncObj) // (1) { Count++; SyncObj.notify(); // (2) } //////////// Sub Thread 1 ~ N //////////// while(true) { synchronized(SyncObj) // (3) { if(Count == 0) { SyncObj.wait(); // (4) } if(Count == 0) // (5) { // (A) ? } Count--; // (6) } // .... } Java의 동기화를 위해서 사용되는 함수로는 wait와 notify(All)가 있다. 특.. 2023. 11. 5.