ITeye博客

JAVA的小圈套

tobemoved · 2008-07-11 10:13 · java代码 · Markdown

public class Test {
    static String s = "abc";
       {
           s.charAt( 0);
           System.out.println(" B");
       }

       static {
           System.out.println(" A");
           s = null;
       }

       public Test() {
           s = "def";
           System.out.println(" C");
       }
       public static void main(String[] args) {
           System.out.println(" E");
           System.out.println(new Test().s);
           System.out.println(" F");
       }
   }

//答案是A,E,外加报错。如果没有s=null的话,答案是A,E,B,C,def,F

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。