mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 17:56:02 +08:00
Update TopKWords.java
This commit is contained in:
@ -20,7 +20,7 @@ public class TopKWords {
|
|||||||
|
|
||||||
fis = new FileInputStream(fileName); // open the file
|
fis = new FileInputStream(fileName); // open the file
|
||||||
int in = 0;
|
int in = 0;
|
||||||
String s = new String(); // init a empty word
|
String s = ""; // init a empty word
|
||||||
in = fis.read(); // read one character
|
in = fis.read(); // read one character
|
||||||
|
|
||||||
while (-1 != in) {
|
while (-1 != in) {
|
||||||
@ -74,7 +74,7 @@ public class TopKWords {
|
|||||||
while (k > list.size()) {
|
while (k > list.size()) {
|
||||||
System.out.println("Retype a number, your number is too large");
|
System.out.println("Retype a number, your number is too large");
|
||||||
input = new Scanner(System.in);
|
input = new Scanner(System.in);
|
||||||
k = new Integer(input.nextLine());
|
k = input.nextInt();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < k; i++) {
|
for (int i = 0; i < k; i++) {
|
||||||
System.out.println(list.get(list.size() - i - 1));
|
System.out.println(list.get(list.size() - i - 1));
|
||||||
|
Reference in New Issue
Block a user