静态代码块

2015-07-06 0 960
静态代码块
 class Parent{ 
static String name = "hello"; 
{ 
System.out.println("parent block"); 
} 
static { 
System.out.println("parent static block"); 
} 
public Parent(){ 
System.out.println("parent constructor"); 
} 
} 

class Child extends Parent{ 
static String childName = "hello"; 
{ 
System.out.println("child block"); 
} 
static { 
System.out.println("child static block"); 
} 
public Child(){ 
System.out.println("child constructor"); 
} 
} 

public class StaticIniBlockOrderTest { 

public static void main(String[] args) { 
new Child();//语句(*) 
} 
}

遇见资源网 java 静态代码块 http://www.ox520.com/9500.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务