
常用软件类: |
|杀毒安全 | |联络聊天 | |网络软件 | |多媒体类 | |系统工具 | |图形图像 | |系统工具 | |应用软件 | |行业软件 |
开发设计类: |
|动画制作 | |图像处理 | |3D设计 | |操作系统 | |站长学院 | |网络相关 | |WEB设计 | |数据库类 | |程序开发 |
| static int x = 1, { //block float sss = 333.3; String str = "hello"; } |
| static { //(static block), int x = 2; double y = 33.3; } |
| /** *//** * * @author livahu * Created on 2006年9月6日, 下午17:00 */ class FirstClass ...{ FirstClass(int i) ...{ System.out.println("FirstClass(" + i + ")"); } void useMethod(int k) ...{ System.out.println("useMethod(" + k + ")"); } } class SecondClass ...{ static FirstClass fc1 = new FirstClass(1); FirstClass fc3 = new FirstClass(3); static ...{ FirstClass fc2 = new FirstClass(2); } ...{ System.out.println("SecondClass's block, this block is not static block."); } SecondClass() ...{ System.out.println("SecondClass()"); } FirstClass fc4 = new FirstClass(4); } public class InitiationDemo ...{ SecondClass sc1 = new SecondClass(); ...{ System.out.println("Hello Java World!"); } public static void main(String[] args) ...{ System.out.println("Inside main()"); SecondClass.fc1.useMethod(100); InitiationDemo idObj = new InitiationDemo(); } static SecondClass sc2 = new SecondClass(); } |
| FirstClass(1) FirstClass(2) FirstClass(3) SecondClass's block, this block is not static block. FirstClass(4) SecondClass() Inside main() useMethod(100) FirstClass(3) SecondClass's block, this block is not static block. FirstClass(4) SecondClass() Hello Java World! |