型の比較やパターンマッチングをinstanceofで行う これを使えばClassCastExceptionを回避できる。 final int NUM = 0; int num = 10; switch (num) { case "10": // numはint,これは文字列で一致していないのでコンパイルエラー System.out.println("A"); break; case num: // ...
調べたい値 instanceof 調べたい値が実装されている型or クラス 調べたい値の型or調べたい値が実装されているクラスの場合 ...
何千人もの開発者が、InfoQのミニブック「Practical Guide to Building an API Back End with Spring Boot」から、Spring Bootを使ったREST API構築の基礎を学んだ。この本では、出版時に新しくリリースされたバージョンである Spring Boot 2 を使用している。しかし、Spring Boot3が最近 ...
米Oracleは3月16日(現地時間)、プログラミング言語「Java」の最新版「Java 16」を発表。Java開発キット「Oracle JDK 16」の提供を開始した。「Java 16」には17のJEP(JDKの改善)が含まれている。なかでも、「Java 14」で初めてプレビューされた言語拡張“Pattern Matching ...
Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources. Cory Benfield discusses the evolution of ...
I bet you don’t like writing ugly but necessary boilerplate code or reading it. But, sometimes we need to create logic that has to deal with an object of unknown type and follow different paths ...
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する