質問編集履歴

1

試行錯誤中のソースを追記いたしました

2021/03/01 11:59

投稿

hinagiku
hinagiku

スコア2

test CHANGED
File without changes
test CHANGED
@@ -105,3 +105,79 @@
105
105
  0005:すもも
106
106
 
107
107
  ```
108
+
109
+ #試行錯誤中のソース
110
+
111
+ ```
112
+
113
+ package Sample;
114
+
115
+
116
+
117
+ import java.util.ArrayList;
118
+
119
+ import java.util.List;
120
+
121
+ import java.util.Map;
122
+
123
+ import java.util.TreeMap;
124
+
125
+
126
+
127
+ public class Sample_4 {
128
+
129
+
130
+
131
+ private static List<List<String>> check = new ArrayList<>();
132
+
133
+
134
+
135
+ public static void main(String[] args) {
136
+
137
+
138
+
139
+ Map<String,String> fruit = new TreeMap<>();
140
+
141
+
142
+
143
+ fruit.put("0001", "りんご");
144
+
145
+ fruit.put("0003", "めろん");
146
+
147
+ fruit.put("0004", "めろん");
148
+
149
+ fruit.put("0005", "すもも");
150
+
151
+ fruit.put("0002", "ばなな");
152
+
153
+
154
+
155
+ for(int i = 0; i < fruit.size(); i++) {
156
+
157
+ List<String> Id = new ArrayList<>();
158
+
159
+ Id.add(fruit.get(i));
160
+
161
+
162
+
163
+ if(check.contains(Id)) {
164
+
165
+ continue;
166
+
167
+ }
168
+
169
+
170
+
171
+ check.add(Id);
172
+
173
+ System.out.println(i + ":" + fruit.get(i));
174
+
175
+ }
176
+
177
+
178
+
179
+ }
180
+
181
+ }
182
+
183
+ ```