PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 30, 2022

[FIXED] How can I take string input for UVA online problem for java only ? Detail information needed

 October 30, 2022     arrays, eof, java, readline, user-input     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing