File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
src/main/java/com/ibrahimatay Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ This repository contains Java examples that are designed to track and document t
4444 * [ JEP 361] ( java-14/src/main/java/com/ibrahimatay/JEP361SwitchExpressions.java ) : Switch Expressions
4545 * [ JEP 359] ( java-14/src/main/java/com/ibrahimatay/JEP359Records.java ) : Records (Preview)
4646 * [ JEP 369] ( java-14/src/main/java/com/ibrahimatay/JEP368TextBlocks.java ) : Text Blocks (Second Preview)
47+ * [ JEP 305] ( java-14/src/main/java/com/ibrahimatay/JEP305PatternMatchingForInstanceof.java ) : Pattern Matching for instanceof (Preview)
4748
4849* [ Java 12] ( java-12/ ) (March, 2019)
4950 * API Improvements
Original file line number Diff line number Diff line change 2323 <artifactId >maven-compiler-plugin</artifactId >
2424 <configuration >
2525 <compilerArgs >--enable-preview</compilerArgs >
26- <source >15 </source >
27- <target >15 </target >
26+ <source >16 </source >
27+ <target >16 </target >
2828 </configuration >
2929 </plugin >
3030 </plugins >
Original file line number Diff line number Diff line change 1+ package com .ibrahimatay ;
2+
3+ public class JEP305PatternMatchingForInstanceof {
4+ public static void main (String [] args ) {
5+ // JEP 305: Pattern Matching for instanceof (Preview)
6+ // https://openjdk.org/jeps/305
7+
8+ Object obj = "JEP305P" ;
9+ if (obj instanceof String ) {
10+ String str = (String ) obj ;
11+ System .out .println (str .toUpperCase ());
12+ }
13+
14+ if (obj instanceof String str ){
15+ System .out .println (str .toUpperCase ());
16+ }
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments