As shown below:
<span style="font-size:24px;"><span style="font-size:24px;">/*Function: judging the size from the keyboard, using an object-oriented method*/import java.io.*; public class Demo1{public static void main(String[] args) {Bijiao bijiao=new Bijiao();bijiao.Bijiao();}} class Bijiao{public void Bijiao(){try{//Input stream, receive number from the keyboard//System.in represents standard input, read from the keyboard InputStreamReader isr=new InputStreamReader(System.in);BufferedReader br=new BufferedReader(isr); //Give a prompt System.out.println("Please enter the first number: "); //Read a line of data from the console String a1=br.readLine(); System.out.println("Please enter the second number: ");String a2=br.readLine(); //Convert string to floatfloat num1=Float.parseFloat(a1); float num2=Float.parseFloat(a2); if (num1>num2){System.out.println("The first number is greater than the second number");}else if (num1==num2){System.out.println("Two numbers are equally large");}else if (num1<num2){System.out.println("The second number is greater than the first number");}}catch (Exception e){e.printStackTrace();}}}</span></span>Running effect:
The above method of java input numbers from the keyboard and judging size is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.