我想获取该程序的输出并将该值存储在另一个变量中,以便以后可以将其用于进一步的操作,例如当我正确运行该程序时,它要求我输入三个数字并假设我输入了5 ,6,7然后显示7是最大,然后我想将7(这是输出权!)存储在另一个变量中
这是我的代码:
import java.util.Scanner;
public class test1 {
public void testThing(){
System.out.println("congrats");
}
public void fun() {
int temp;
Scanner in = new Scanner(System.in);
temp = in.nextInt();
}
public void exrExr() {
Scanner in = new Scanner(System.in);
System.out.println("hello there!");
int a,b,c;
System.out.println("We'll start with a,b and c,enter their values accordingly : ");
a = in.nextInt();
System.out.println("a = " + a);
b = in.nextInt();
System.out.println("b = " + b);
c = in.nextInt();
System.out.println("c = " + c);
System.out.println("if you were wondering,among your entered numbers");
if ( a>b && a>c ) {
System.out.println("a is largest");
int temp = a;
}
else if (b>a && b>c) {
System.out.println("b is largest");
}
else if (c>a && c>b) {
System.out.println("c is largest");
}
else if (a==b && a==c && b==c)
System.out.println("all of them are same");
test1 test1Object = new test1();
test1Object.fun();
}
}