This is my current code, fairly basic, I'm adding names to an array and deleting said names using scanners. Like I said basic stuff. I'm using a switch since it makes my life 100000x easier than just using a bunch of if's and it's a nicer layout regardless.
The following is my code:
import java.util.Scanner;
import java.util.ArrayList;
public class Account
{
public static void main (String [] args)
{
Scanner sc = new Scanner (System.in);
ArrayList list = new ArrayList();
boolean quit = false;
do
{
System.out.println ("MENU\n 0: Enter name to list\n 1: Delete name from list\n 2: Print Current List\n 3: Quit");
int input = sc.nextInt();
switch(input)
{
case 0:
System.out.println ("Enter name to add to list");
list.add(sc.nextLine());
System.out.println("Name has been added");
System.out.println (list);
break;
case 1:
System.out.println("Enter name to remove");
list.remove(sc.next());
System.out.println (list);
break;
case 2:
System.out.println (list);
break;
case 3:
quit = true;
break;
default:
System.out.println ("Invalid choice");
}
}while(!quit);
System.out.println ("Exiting menu");
}
}
My issue is that once I enter 0 to go to the first case, it seems as though it just skips the user entry and outputs an empty string. If I were to do that exact same procedure outside of my switches it seems to work, so it makes me think that something might be up with my scanner. Possibly has something to do with the int scan I made right before to get into the case? But I could have sworn I've done something like this dozens of times...
I should also mention that sc.next() works fine, its just sc.nextLine() that seems to be giving me stress.