I'm getting weird results from the System.out.print immediately below the Scanner declaration in the code snippet below. It seems like it's executing twice. I've debugged it and immediately after executing the print statement I get this in standard out:
run: Input a freaking binary number: Input a freaking binary number:
I added the "freaking" to verify it wasn't somehow entering the while loop print without me knowing.
For your info this is being executed in the netbeans IDE 6.7.1 on a 64 bit vista machine with the 64 bit JDK. Hopefully you can see the error of my ways!
Thanks!
Edit: When executing the Netbeans generated JAR file on the command line the statement only prints once. Has anyone encountered this kind of weird behavior in Netbeans that might know how I can prevent this from happening. I hate having to work outside my IDE during development cycles.
private void getInput()
{
Scanner scanner = new Scanner(System.in);
System.out.print("Input a freaking binary number: ");
// Grab the next inputed long and save it in the currentValueInBinary
// member variable
setCurrentValueInBinary(scanner.nextLong());
// Loop until a valid binary number is retrieved
while (!isNumberBinary(currentValueInBinary))
{ // Input was negative, report error and re-request input
System.out.println("Input must be a Binary value");
System.out.print("\nInput a binary number: ");
setCurrentValueInBinary(scanner.nextLong());
}
}