问几个java问题
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 12 楼,当前显示第 7 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:bigfox (等级:4 - 马马虎虎,发帖:2214) 发表:2004-06-30 16:01:17  7楼 
Answers:1) Of course no error, since you are accessing t.myString inside t itself! Note that your main method is part of the MyThread class. Furthermore, Java's default access specification for member variables and methods is NOT private! The default specification allows access from any class in the same package. As your MyThread class is not in any package (effectively in the so-called "global" package), and I suppose so is your other test classes, myString is accessible. 2) The x in the first static scope cannot be accessed, because it is destroyed straightaway after it is declared! Note that static {...} structure is usually useful only in the global scope, i.e., outside any class. Basically, it provides static initialization routines to be executed before everything else (of course, there are still necessary initializations like class loading before this). Don't confuse the static code fragment with static member variable of a class.
are u saying that
any var(s) declared within static{} will not be reachable any more after the control flow gets out of that block?

pls correct me if i am wrong. 3x :D
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 12 楼,当前显示第 7 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码