问几个java问题
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 12 楼,当前显示第 12 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:Flying (等级:18 - 华新水车,发帖:16849) 发表:2004-07-01 08:22:33  12楼 
are u saying thatany 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
Yes.
Static initializer blocks behave like static methods in the class, with all method names, argument lists, and return types stripped.

All static initializers declared in a class are executed exactly once, in the order of their declarations, when the class is first loaded. Therefore, static initializer are popular when you need to initialize static class member variables with logic that exceeds what a single-line expression initializer can do.

Therefore, with the basic scoping rule, I suppose local variables should not be accessible from outside of a static initializer block.
Flying @way 吳穎暉
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

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



请登录后回复:帐号   密码