java2从头开学(13)

java2从头开学(13)

package 数据类型;
//作用域
class Scope {
 public static void main(String args[]){
  int x;
  
  x = 10;
  if(x == 10){
   int y = 20;
   
   System.out.println("x and y: " + x + " " + y);
   x = y * 2;
  }
  // y = 100;//Error! y not known here
  
  // x is still known here.
  System.out.println("x is " + x);
 }

}

你可能感兴趣的:(java2从头开学(13))