final对基本类型,限定常量。

final对对象的引用,不可引用其他对象。

final的字段,必须在定义时或者构造器内完成初始化。构造内才完成初始化的Blank Final(空白final)。

class Poppet
{
	private int i ;
	public Poppet(int ii)
	{
		i = ii;
	}
}

class BlankFinal
{
	private int i = 100;
	private final int j ;
	private final Poppet p;

	//BlankFinal field must be init in constructor
	public BlankFinal()
	{
		j = 10;
		p = new Poppet(10);
	}

	public BlankFinal(int x)
	{
		j = x;
		p = new Poppet(x);
	}
}

  

05-11 15:14