When the below code (see How-To-Repeat) is compiled and run, the program waits for input after initializing the Scanner. That input is then returned to the first input.next() call, and each input.next() call returns the user input given during the previous call.
Environment: System: Linux hybrid 2.6.27-zen3-4.2.0 #2 SMP Sat Oct 25 12:29:11 EDT 2008 x86_64 GNU/Linux host: x86_64-unknown-linux-gnu build: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu configured with: ../trunk/configure --program-suffix=-svn --enable-languages=c,c++,java --with-x --enable-java-awt=xlib How-To-Repeat: Compile and run a file containing the following code: import java.util.Scanner; public class Test { public static void main(String argv[]) { Scanner input = new Scanner(System.in); System.out.print("Enter a string: "); String foo = input.next(); System.out.println(foo); System.out.print("Enter a string: "); foo = input.next(); System.out.println(foo); input.close(); } } -- Summary: Scanner(System.in) causes next*() to behave incorrectly Product: gcc Version: 4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jre21 at case dot edu GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38075