File tree Expand file tree Collapse file tree 6 files changed +46
-52
lines changed
Collections/src/main/java/map
src/main/java/com/saurabh/java Expand file tree Collapse file tree 6 files changed +46
-52
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ jobs:
1616
1717 steps :
1818 - uses : actions/checkout@v4
19- - name : Set up JDK 22
19+ - name : Set up JDK 23
2020 uses : actions/setup-java@v4
2121 with :
22- java-version : 22
22+ java-version : 23
2323 distribution : ' temurin'
2424 - name : Build with Maven JavaCon
2525 run : mvn -B package --file JavaCon/pom.xml
Original file line number Diff line number Diff line change 1+ package map ;
2+
3+ import java .util .HashMap ;
4+
5+ public class MapWithChangedKey {
6+
7+ public static void main (String [] args ) {
8+ sb ();
9+ string2 ();
10+ }
11+
12+ private static void sb () {
13+ final var map = new HashMap <StringBuilder , String >();
14+ final var key1 = new StringBuilder ("key1" );
15+ final var key2 = new StringBuilder ("key2" );
16+
17+ map .put (key1 , "value1" );
18+ map .put (key2 , "value2" );
19+
20+ key1 .append ("__changed" );
21+
22+ System .out .println ("sb value for key1: " + map .get (key1 ));
23+ System .out .println ("sb value for key1: " + map .get (new StringBuilder ("key1__changed" )));
24+ System .out .println ("sb value for key2: " + map .get (new StringBuilder ("key2" )));
25+ }
26+
27+ private static void string2 () {
28+ final var map = new HashMap <String , String >();
29+ var key1 = "key1" ;
30+ final var key2 = "key2" ;
31+
32+ map .put (key1 , "value1" );
33+ map .put (key2 , "value2" );
34+
35+ key1 += "__changed" ;
36+
37+ System .out .println ("sb value for key1: " + map .get (key1 ));
38+ System .out .println ("sb value for key1: " + map .get ("key1__changed" ));
39+ System .out .println ("sb value for key2: " + map .get ("key2" ));
40+ }
41+ }
Original file line number Diff line number Diff line change 1717 <groupId >org.apache.maven.plugins</groupId >
1818 <artifactId >maven-compiler-plugin</artifactId >
1919 <configuration >
20- <release >22 </release >
20+ <release >23 </release >
2121 <compilerArgs >--enable-preview</compilerArgs >
2222 </configuration >
2323 </plugin >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public static void main(String[] args) {
1515 try {
1616 throw new IllegalArgumentException ("test" );
1717 } catch (IllegalStateException _) {
18- System .out .println (STR . "Got an illegal state exception for: \{car .name ()}" );
18+ // System.out.println("Got an illegal state exception for: \{car.name()}");
1919 } catch (RuntimeException _) {
2020 System .out .println ("Got a runtime exception!" );
2121 }
Original file line number Diff line number Diff line change 1515
1616 <properties >
1717 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
18- <maven .compiler.release>22 </maven .compiler.release>
18+ <maven .compiler.release>23 </maven .compiler.release>
1919
2020 <!-- testing -->
2121 <junit-jupiter .version>5.11.3</junit-jupiter .version>
You can’t perform that action at this time.
0 commit comments