Java receive console input parameter InputStreamReader

Source: Internet
Author: User
Import Java.io.bufferedreader;import java.io.inputstreamreader;//InputStreamReader class in java.io public class Rawinput { /** receive console input data * Determine if this two data is equal */public static void main (string[] args) {Try{inputstreamreader ISR = new InputStreamReader (Sy stem.in);//use BufferedReader to put data into buffer bufferedreader br = new BufferedReader (ISR); System.out.println ("Please enter a number:"); String S1 = Br.readline (); String s2 = Br.readline ();//The data entered by the console is treated as a string by default and needs to be converted to a number//string to Floatfloat F1 = float.parsefloat (S1); Float F2 = F Loat.parsefloat (S2); if (f1 = = F2) {System.out.println ("equal");} Else{system.out.println ("unequal");}} catch (Exception e) {e.printstacktrace ();}}

Java receive console input parameter InputStreamReader

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.