需求:动物园里有两只老虎,已知两只老虎的体重分别为180kg、200kg,请用程序实现判断两只老虎体重是否相同。
1 public class Main { 2 public static void main(String[] args) { 3 int weight1 = 180; 4 int weight2 = 200; 5 //使用三目运算符实现老虎体重的判断 6 boolean b = weight1 == weight2 ? true : false; 7 8 System.out.println("b:" + b); 9 10 } 11 }
运行结果:
标签:__,两只,int,老虎,002,weight2,Java From: https://www.cnblogs.com/yiqiesuifeng/p/17688534.html