---
title: "super和this"
author: "uqortbsa"
date: "2010-09-24T22:54:13Z"
tags: []
categories: ["编程语言"]
slug: "super-this"
draft: false
lastmod: "2010-09-24T22:54:13Z"
id: 770704
url: "https://uqortbsa.iteye.com/blog/770704"
---

```java

class Person {
	public static void prt(String s) {
		System.out.println(s);
	}

	Person() {
		prt("A Person.");
	}

	Person(String name) {
		prt("A person name is:" + name);
	}
}

public class Chinese extends Person {
	Chinese() {
		super(); // 调用父类构造函数
		prt("A chinese.");//
	}

	Chinese(String name) {
		super(name);// [b]调用父类具有相同形参的构造函数[/b]
		prt("his name is:" + name);
	}

	Chinese(String name, int age) {
		this(name);// [b]调用当前具有相同形参的构造函数[/b]
		prt("his age is:" + age);
	}

	public static void main(String[] args) {
		Chinese cn = new Chinese();
		cn = new Chinese("kevin");
		cn = new Chinese("kevin", 22);
	}
}

```