Update Main.java

fixing bug
Program is causing a NoSuchElementException
This commit is contained in:
Alexandra Englert
2020-03-20 21:56:35 +01:00
parent ecfbadc789
commit dd73b46a25

View File

@ -8,6 +8,7 @@ public class Main {
int choice, key; int choice, key;
HashMap h = new HashMap(7); HashMap h = new HashMap(7);
Scanner In = new Scanner(System.in);
while (true) { while (true) {
System.out.println("Enter your Choice :"); System.out.println("Enter your Choice :");
@ -15,9 +16,7 @@ public class Main {
System.out.println("2. Delete Key"); System.out.println("2. Delete Key");
System.out.println("3. Print Table"); System.out.println("3. Print Table");
System.out.println("4. Exit"); System.out.println("4. Exit");
Scanner In = new Scanner(System.in);
choice = In.nextInt(); choice = In.nextInt();
switch (choice) { switch (choice) {
@ -39,10 +38,11 @@ public class Main {
break; break;
} }
case 4: { case 4: {
In.close();
return; return;
} }
} }
In.close();
} }
} }
} }