After using next() to skip the extra line after a user entry I try and get nextLine() to pick up the variable name that the user is currently entering. My program is using a text based menu and this is the only way I have been able to make the menu flow smoothly (along with a do-while loop and what have you but I digress) My problem is this: while I know that the object that I am trying to name is receiving data from my main method, it is not giving it the proper name, just giving it a blank character. I know this because it renames the object, but it does not rename the object correctly, it just gives in a space (i give the name variable for the object a "N/A" in the constructor method). How can I combat this problem now and in the future?
Main method snippit
String last;
selector = in.nextInt();
if (selector == 1)
{
System.out.print("Please enter Last Name: ");
in.next();
last = in.nextLine();
entry.setLast(last);
terminator = true;
}
Object naming method
private static String last_name;
public static String setLast(String a)
{
last_name = a;
return last_name;
}
this seems like a simple problem but I need some outside perspective! I do not think that im focusing on the true issue here. Thank you