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);
 }

}

posted on 2008-04-11 14:35 dripstone 阅读(189) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿(1)

随笔分类(1)

随笔档案(16)

友情链接

搜索

最新评论

阅读排行榜

评论排行榜