89-三目运算符

package com.chongrui.test;
//测试全局变量及局部变量的输出结果的异同
public class Gess {
static int times = 1;
public static void main (String[] args){

int times = 4;
int times2 = 8;
int z = times< times2?120:22;
System.out.println("输出三目运算的值"+z);
System.out.println("输出全局变量"+Gess.times);
System.out.println("输出局部变量"+times);


}


}

 

输出三目运算的值120
输出全局变量1
输出局部变量4

 

如果int z = times>times2?120:22;   输出的值是22

posted @ 2016-12-24 17:43  tantanba  阅读(135)  评论(0编辑  收藏  举报