Strange System.out.print behavior in NetBeans

I am getting strange results from System.out.print directly below the Scanner declaration in the below code snippet. It seems to execute twice. I debugged it and immediately after executing the print instruction I got this in standard form:

mileage: Enter a double number: Enter an arbitrary binary number:

I added "freaking" to make sure it didn't somehow go into the while loop without me.

For your information, this is done in netbeans IDE 6.7.1 on a 64 bit Vista machine with a 64 bit JDK. Hope you see my paths bug!

Thank!

Edit: When executing a JAR file generated by NetBeans on the command line, the statement only outputs one time. Has anyone encountered this kind of strange behavior in Netbeans that might know how I can prevent this. I don't like working outside of 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());
    }
}

      

+2


source to share


1 answer


"2 spaces after:" in printing (String s) error in Netbeans?

In line:



System.out.print ("Entering an enchanted binary number:");

remove the second trailing space.

+3


source







All Articles