Answers:
所在版块:求学狮城 发贴时间:2004-06-29 18:03

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
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.
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Flying @way 吳穎暉
 相关帖子 我要回复↙ ↗回到正文
问几个java问题 bigfox   (946 bytes , 633reads )
ur mails...got a lot...how? 小蹦   (0 bytes , 233reads )
really? help me pass them to 阿修罗 bah 3x 3x bigfox   (0 bytes , 376reads )
只要不是来自PR/UOB, 就不是很急. bigfox   (69 bytes , 307reads )
java tutorial from Sun is always a good resource to consult 香陵居士   (591 bytes , 284reads )
What's SCJP? Flying   (58 bytes , 294reads )
not suit for u at all. bigfox   (86 bytes , 373reads )
That's it lo... there are always long staircases to climb... Flying   (0 bytes , 280reads )
Hoho, if you are good enough to get SCEA, can got for it directly. ;) 香陵居士   (0 bytes , 232reads )
Answers: Flying   (944 bytes , 296reads )
are u saying that bigfox   (150 bytes , 404reads )
Yes. Flying   (582 bytes , 271reads )