---
title: "Java 执行顺序"
author: "shenghw"
date: "2012-12-22T12:42:40Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2012-12-22T12:48:47Z"
id: 1752330
url: "https://wuning.iteye.com/blog/1752330"
---

```java

class T {
	T() {
		System.out.println("super construct");
	}

	{
		System.out.println("super no static ");
	}
	static {
		System.out.println("super  static ");
	}
}

public class E extends T {
	E() {
		System.out.println("construct");
	}

	static int a = 0;

	{
		System.out.println("no static c");
	}
	static {
		System.out.println("static ");
	}

	public static void main(String args[]) {
		System.out.println("后于静态代码段执行");
		new E();

	}
}


```

执行结果如下：

super  static 
static 
后于静态代码段执行
super no static 
super construct
no static c
construct