首页 > 代码库 > Java之容器

Java之容器

1. 容器的概念:

class Name {
	private String firstName, lastName;
	public Name(String firstName, String lastName) {
		this.firstName = firstName;
		this.lastName = lastName;
	}
	public String getFirstName() {
		return firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public String toString() {
		return firstName+"  "+lastName;
	}
}
public class Test {
	public static void main(String[] args) {
		Name n1 = new Name("f1","l1");
		Name n2 = new Name("f2","l2");
		Name n3 = new Name("f3","l3");
	}
}

  容器:Java API 所提供的一系列类的实例,用于在程序中存放对象.

     数组一旦定义大小,无法改变.

2. 容器 API:

  2.1

Java之容器