---
# System prepended metadata

title: 範例

---

# 範例
```java=
public class GetDBNew extends GetDB {
	// 要加入的新屬性
	private String num;
	private String age;

	public GetDBNew(int id, String num, String name, String age, String email) {
		super(id, name, email);// 父類別的內容
		this.num = num;
		this.age = age;
	}

	public String getDB() {
		return num + age;
	}

}

```
```java=
public class GetDB {

	// 設置屬性
	private int id;
	private String name;
	private String email;

	// 初始化
	public GetDB(int id, String name, String email) {
		super();
		this.id = id;
		this.name = name;
		this.email = email;
	}

	// 建構子
	public String getDB() {
		return id + name + email;
	}

}

```
```java=
public class MyGetDB {

	public static void main(String[] args) {
		GetDB db= new GetDB(1, "Tim", "t@mail.coms");
		GetDBNew dbn =new GetDBNew(2, "30", "Yam", "25", "y@mail.com");

	}

}
```