Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4812

System.out.print() statements placed before Scanner calls, such as scanner::next(), do not output until after input is entered only in Netbeans console

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 12.0
    • Fix Version/s: None
    • Environment:
    • Flags:
      Patch, Important

      Description

      I have a program that runs perfectly fine in both the terminal and in Intellij, but then when the Java code is run inside a NetBeans project, it outputs incorrectly.

      (Before I continue the description, I have a video here and the project itself is attached to this report)

      The following is the first code that ran into the problem:

       

      System.out.print("\nPlease enter a month and year (e.g. Sep 2020): ");
      selectedMonth = Month.valueOf(keyboard.next().toUpperCase());
      selectedYear = keyboard.nextInt();
      

       

      In Intellij and the terminal this was the output (which is correct):

      Welcome to Keegan Bilodeau's Calendar Application!
      
      
      Please enter a month and year (e.g. Sep 2020): l
      Error: You did not enter a valid month!
      
      
      Please enter a month and year (e.g. Sep 2020): 
      

       

      This is the output in NetBeans (which is wrong):

      Welcome to Keegan Bilodeau's Calendar Application!
      l
      Please enter a month and year (e.g. Sep 2020): Error: You did not enter a valid month!
      

       

      **Something to note is that when the System.out.print() is changed to System.out.println(), the code runs properly, but with a newline, which is not what I wanted nor should be necessary.  One might assume that it was because System.out.println() flushes the stream; however, Using System.out.print() in conjunction with System.out.flush() changed nothing

       

      For even more information regarding the issue, see the attached files.

        Attachments

        1. CSCI_2011_Assign_1.zip
          18 kB
          Keegan Bilodeau

          Activity

            People

            • Assignee:
              SiddheshRane Siddhesh Rane
              Reporter:
              Ardente Keegan Bilodeau
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 336h
                336h
                Remaining:
                Remaining Estimate - 336h
                336h
                Logged:
                Time Spent - Not Specified
                Not Specified