-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cast to interface logic (along with TreeMap test)
- Loading branch information
1 parent
b1c4c8c
commit 320dd29
Showing
9 changed files
with
92 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package samples.javabase.util.treemap.trivial; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class TrivialTreeMap { | ||
public static void main(String[] args) { | ||
int result = getSum(); | ||
} | ||
|
||
private static int getSum() { | ||
Map<Integer, Integer> map = new TreeMap<>(); | ||
map.put(1, 10); | ||
map.put(2, 20); | ||
map.put(3, 30); | ||
|
||
map.remove(2); | ||
map.put(1, 50); | ||
|
||
int sum = 0; | ||
for (var entry : map.entrySet()) { | ||
sum += entry.getKey() + entry.getValue(); | ||
} | ||
return sum; | ||
} | ||
} |
Binary file modified
BIN
+538 Bytes
(180%)
tests/test_data/samples/javabase/util/hashmap/trivial/TrivialHashMap.class
Binary file not shown.
Binary file added
BIN
+1.15 KB
tests/test_data/samples/javabase/util/treemap/trivial/TrivialTreeMap.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters