回答編集履歴

1

追記

2022/01/18 13:08

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -25,3 +25,34 @@
25
25
  ```
26
26
  こういうことがしたいのですか?
27
27
 
28
+ **追記**
29
+ あるいは、こういうことですか?
30
+ ```java
31
+ import java.util.*; // Map, HashMap
32
+
33
+ class Main {
34
+ public static void main(String[] args) {
35
+ Entry.enter(new Data().map);
36
+ }
37
+ }
38
+
39
+ class Entry {
40
+ public static void enter(Map map) {
41
+ System.out.println(map.get("オレンジ"));
42
+ }
43
+ }
44
+
45
+ class Data {
46
+ public Map<String, Integer> map = new HashMap<>();
47
+
48
+ public Data() {
49
+ map.put("リンゴ", 80);
50
+ map.put("オレンジ", 120);
51
+ map.put("ブドウ", 90);
52
+ }
53
+ }
54
+ ```
55
+ static や new の意味が分からないのですか?
56
+
57
+
58
+