From 0cf0aba68a16a6114779aaa640fa688fb2cf6368 Mon Sep 17 00:00:00 2001 From: Keqi Huang Date: Mon, 9 Apr 2018 09:16:06 -0500 Subject: [PATCH] Update TopKWords.java --- Others/TopKWords.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Others/TopKWords.java b/Others/TopKWords.java index 96139f68fbca..e2d3c6fa533a 100644 --- a/Others/TopKWords.java +++ b/Others/TopKWords.java @@ -20,7 +20,7 @@ public Map getDictionary() { fis = new FileInputStream(fileName); // open the file int in = 0; - String s = new String(); // init a empty word + String s = ""; // init a empty word in = fis.read(); // read one character while (-1 != in) { @@ -74,7 +74,7 @@ public static void main(String[] args) { while (k > list.size()) { System.out.println("Retype a number, your number is too large"); input = new Scanner(System.in); - k = new Integer(input.nextLine()); + k = input.nextInt(); } for (int i = 0; i < k; i++) { System.out.println(list.get(list.size() - i - 1));