变量声明和初始化

public class VarDemo {
 
public static void main(String[] args) {
// TODO Auto-generated method stub
int age; //声明,定义
age =16; //初始化
age =15;//赋值
System.out.println(age); //输出15
int core = 100;
core = 200;
System.out.println(core);
if(core>100){
int iq = 80; //作用域,只在if函数快内可以使用,跳出范围则无效
System.out.println(iq);
}
int iq =100;
System.out.println(iq);
}
 
}

猜你喜欢

转载自smilezhw.iteye.com/blog/2313870