質問するログイン新規登録

回答編集履歴

1

コードのデバッグ

2017/01/12 04:07

投稿

seastar3
seastar3

スコア2287

answer CHANGED
@@ -11,10 +11,8 @@
11
11
  class relayUserVnue{
12
12
  public static void main(String args[]){
13
13
 
14
- // 文字列ビルダーオブジェクトを用意
15
- StringBuilder builder = new StringBuilder();
16
14
  // 会場IDのハッシュ(連想配列)を用意
17
- HashMap<String,int> venueIdMap = new venueMap<String,int>();
15
+ HashMap<String,Integer> venueIdMap = new venueMap<String,Integer>();
18
16
 
19
17
  venueIdMap.put("alkjf;akjdf", 101);
20
18
  venueIdMap.put("odfka:lsdfk", 102);
@@ -33,26 +31,25 @@
33
31
  // 入力データファイルを仮に"UserVenueStar.txt"としている
34
32
  try (BufferedReader reader = new BufferedReader(new FileReader("UserVenueStar.txt"))) {
35
33
  String strData = reader.readLine();
36
- String[] array;
34
+ String[] strItem;
37
35
  int userId, venueId, star;
38
36
  System.out.println("userID venueID star");
39
37
  while (strData != null){
40
- builder.append(string + System.getProperty("line.separator"));
41
38
  strData = reader.readLine();
42
- array = strData.split(" ");
39
+ strItem = strData.split(" ");
43
- if (userIdMap.containsKey(strData[0])){
40
+ if (userIdMap.containsKey(strItem[0])){
44
- userId = userIdMap.containsKey(strData[0]);
41
+ userId = userIdMap.containsKey(strItem[0]);
45
42
  }else{
46
43
  userId = 0;
47
44
  }
48
45
 
49
- if (venueIdMap.containsKey(strData[1])){
46
+ if (venueIdMap.containsKey(strItem[1])){
50
- venueId = venueIdMap.containsKey(strData[1]);
47
+ venueId = venueIdMap.containsKey(strItem[1]);
51
48
  }else{
52
49
  venueId = 0;
53
50
  }
54
51
 
55
- star = strData[2];
52
+ star = sstrItem[2];
56
53
  System.out.println(userId + " " + venueId + " " + star);
57
54
  }
58
55
  } catch (Exception e) {