回答編集履歴
3
bug fix
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
String[] elements = line.split("\t", 0);
|
66
66
|
|
67
|
-
if (tsvMap.containsKey(elements[0])) {
|
67
|
+
if (!tsvMap.containsKey(elements[0])) {
|
68
68
|
|
69
69
|
List<String> values = new ArrayList<>();
|
70
70
|
|
2
typo
test
CHANGED
@@ -64,15 +64,15 @@
|
|
64
64
|
|
65
65
|
String[] elements = line.split("\t", 0);
|
66
66
|
|
67
|
-
if (tsv.containsKey(elements[0])) {
|
67
|
+
if (tsvMap.containsKey(elements[0])) {
|
68
68
|
|
69
69
|
List<String> values = new ArrayList<>();
|
70
70
|
|
71
|
-
tsv.put(elements[0], values);
|
71
|
+
tsvMap.put(elements[0], values);
|
72
72
|
|
73
73
|
}
|
74
74
|
|
75
|
-
tsv.get(elements[0]).add(elements[1]);
|
75
|
+
tsvMap.get(elements[0]).add(elements[1]);
|
76
76
|
|
77
77
|
}
|
78
78
|
|
1
変数名の変更と、HashMapの拡張forが構文エラーな点を修正
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
public static void main(String args[]) {
|
34
34
|
|
35
|
-
|
35
|
+
List<String> lines = new ArrayList<>();
|
36
36
|
|
37
37
|
try {
|
38
38
|
|
@@ -62,17 +62,17 @@
|
|
62
62
|
|
63
63
|
for(String line : lines){
|
64
64
|
|
65
|
-
String[]
|
65
|
+
String[] elements = line.split("\t", 0);
|
66
66
|
|
67
|
-
if (tsv.containsKey(
|
67
|
+
if (tsv.containsKey(elements[0])) {
|
68
68
|
|
69
69
|
List<String> values = new ArrayList<>();
|
70
70
|
|
71
|
-
tsv.put(
|
71
|
+
tsv.put(elements[0], values);
|
72
72
|
|
73
73
|
}
|
74
74
|
|
75
|
-
tsv.get(
|
75
|
+
tsv.get(elements[0]).add(elements[1]);
|
76
76
|
|
77
77
|
}
|
78
78
|
|
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
public static void display(HashMap<String,List<String>> tsvMap){
|
86
86
|
|
87
|
-
for (
|
87
|
+
for (Entry<String, List<String>> entry : tsvMap.entrySet()) {
|
88
88
|
|
89
89
|
System.out.println(entry.getKey() + "\t" + String.join(":",key.getValue()));
|
90
90
|
|