import java.util.Scanner;
class Compare
{
private int a; /*整型变量成员a*/
private int b; /*整型变量成员b*/
public int scanInt(String type)
{
Scanner scan = null;
while (true)
{
try{/*异常捕捉*/
scan = new Scanner(System.in);
System.out.print("请输入"+type+"的值:");
return scan.nextInt();
}catch(Exception e){/*异常处理*/
System.out.println("你输入的数据错误!");
}
}
}
public void compareInt()/*比较后输出大小关系*/
{
if(a==b)
System.out.println(a+"="+b);
else
System.out.println(a>b?a+">"+b:a+"<"+b);
}
public static void main(String[] args)
{
Compare c = new Compare();
c.a = c.scanInt("a");
c.b = c.scanInt("b");
c.compareInt();
}
}
import java.util.Scanner;
public class Relation {
public static void main(String args[]){
System.out.println("请输入两个数,每输入一个数用回车确认");
Scanner reader=new Scanner(System.in);
int x,y; // 声明两个整型变量
// 分别赋值
x = reader.nextInt();
y = reader.nextInt();
if (x>y)
System.out.printf("x>y");
else if (x
System.out.printf("x==y");
}
}
public class IntSort {
public static void main(String []args) {
int a = 10;
int b = 13;
System.out.println(a > b ? a : b);
}
}
不知道是不是你要的
public class Example1_1 {
public static void main(String[] args) {
int a, b;
a = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
System.out.println(a > b ? a : b);
}
}