computer 版 (精华区)

发信人: arbo (arbo), 信区: program
标  题: java上课笔记1
发信站: 听涛站 (2001年09月17日10:40:30 星期一), 站内信件

发信人: airforce1 (五湖废人), 信区: Java
标  题: java上课笔记1
发信站: BBS 水木清华站 (Sat Apr  1 11:26:59 2000)

随手写些老师讲的东西,不难。
static ,
class A{
  static int i=5;
  static { System.out.println("staticc code i="+i++);}
}
public class test{
  public static void main(String args[]){
  System.out.println("main code: i="+ A.i);
}
}
the result:
static code: i=5;
Main code : i=6

"static block" executes just once. (a constructor will execute when
every time the object is newed.)

final keyword.
you can not extend a class from a final class.
another thing is , in c/c++, use const to declare a variable is not writeable.
in java, final variable is a constant.

--
--
※ 来源:·听涛站 tingtao.dhs.org·[FROM: 匿名天使的家] 
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:0.828毫秒