I get two different outputs for the same code. I get one result when I debug and scan each line (using Netbeans 8.1). And I get a different result when I run the code right away.
This is the code
public class Testing { public static void main(String... args) throws IOException { BufferedReader file = new BufferedReader(new FileReader("input")); String str = file.readLine(); System.out.println(str); } }
This is the input file.
first second third fourth
In both cases, the code should print the first line of first . But this only happens when I run the code.
If I debug the code and go through each line, the second line of second is printed.
Why is this happening?
Update: Below is a screenshot of the debugging screen. Right now, if I step over, it will execute the line System.out.println. As you can see on the right, str contains "second".

java netbeans
Quazi irfan
source share