Issue
I am trying to string input for UVA online judge problem using JAVA.
like C++
while(s = getchar()) {
if(s == EOF)
}
Solution
import java.util.Scanner;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a string.");
String str = scanner.nextLine();
Is this what you're looking for? If you're reading from a file,
import java.io.File;
Scanner scanner = new Scanner(new File("path.txt"));
while (scanner.hasNextLine()) {
String str = scanner.nextLine();
//...
}
Answered By - ROBOKiTTY Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.