Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Scanner/Eclipse(Using scanner)
Scanner/Eclipse [message #1745351] Fri, 07 October 2016 17:43 Go to next message
Murali Mani is currently offline Murali ManiFriend
Messages: 1
Registered: October 2016
Junior Member
I wrote a simple program to loop and find max of a set of numbers input by the user as:

import java.util.Scanner;

public class Welcome1 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int currMax, currEl;
currMax = sc.nextInt();

while (sc.hasNext()) {
currEl = sc.nextInt();
currMax = (currEl > currMax ? currEl : currMax);
}
sc.close();
System.out.println(currMax);
} // end function main

}

-------------------------

When I run it from Windows, the first time it runs fine, and considers Ctrl-Z as EOF and exits the loop. But second time onwards, it does not seem to read the EOF. I am unable to explain this, or fix this behavior.. what do you think is going on, and how do I fix it??

best, murali.





Re: Scanner/Eclipse [message #1745356 is a reply to message #1745351] Sat, 08 October 2016 03:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30450
Registered: July 2009
Senior Member
This is not an Eclipse question. Better to use something like stackoverflow for Java programming questions.
Previous Topic:Eclipse Memory View Tool
Next Topic:Problems by typing commands in Remote Shell
Goto Forum:
  


Current Time: Wed Sep 18 12:07:57 GMT 2019

Powered by FUDForum. Page generated in 0.03105 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top