int a = 123;
int b = 132;
int c = 213;
System.out.println(a > (b>c ? b:c) ? a : (b>c? b:c));怎么打印最大的数是“c”基础学多久 2个月够吗
int b = 132;
int c = 213;
System.out.println(a > (b>c ? b:c) ? a : (b>c? b:c));怎么打印最大的数是“c”基础学多久 2个月够吗
调试欢乐多
public class Test{ public static void main(String[] args){ int a = 123;
int b = 132;
int c = 213; System.out.println("c的值是:");
System.out.print(a > (b>c ? b:c) ? a : (b>c? b:c));
System.out.println("打印字符C");
System.out.println(a > (b>c ? b:c) ? "a" : (b>c? "b":"c"));
}
}
a >= b && a >= c ? 'a' :
b >= a && b >= c ? 'b' :
'c'
);
if(b>max)
max=b;
if(c>max)
max=c;
System.out.println(max);
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Comparator;public class Test {
int aVar = 123;
int bTem = 132;
int cGoooo = 213; // 名字随便取,不限于a, b, c public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {
final Test t = new Test();
Field[] fields = Test.class.getDeclaredFields();
Arrays.sort(fields, new Comparator<Field>() {
@Override
public int compare(Field f1, Field f2) {
try {
return f2.getInt(t) - f1.getInt(t);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return 0;
}
}); // 打印出整数值最大的变量的名字
System.out.println(fields[0].getName());
}
}
public static void main(String []args){
test t=new test();
int result=t.m1(123,132,213);
System.out.println(result);
}
public int m1(int a,int b,int c){
int max;
if(a>b)
if(a>c)
max=a;
else
max=c;
else
if(b>c)
max=b;
else
max=c;
return max;
}
}
1.这样就可以打印出c:
int a = 123;
int b = 132;
int c = 213;
System.out.println(a > (b>c ? b:c) ? "a" : (b>c? "b":"c"));
2.因人而异,看你对这段代码的理解,2个月明显不够