object 类是所有对象的父类
equals比较的是两个对象的地址
instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例
内部类
类中有类
可以用private修饰内部类
内部类可以直接访问外部类中的成员(包括私有的)
因为成员前面使用了修饰符outer
静态内部类只能访问静态外部类中的静态成员
外部类访问内部类需要建立内部类对象
访问内部类对象时需要带上外部类名
外部类.内部类 name = new 外部类().new内部类()
内部类的成员有静态的改内部类也为静态的
内部类定义在局部时,不可以被成员修饰符修饰
可以直接访问外部类中的成员,
但是不可以访问它所在的局部中的变量
只能访问被final修饰的局部变量
匿名内部类
new 父类或接口()
{
子类的内容;
}
匿名内部类就是一个匿名子类对象,是一个带内容的对象
interface inter
{
void method();
}
class test
{
/*
static class inter implements inter
{
public void method()
{
system.out.println("method run");
}
}
*/
//等于下面的代代码
static inter function()
{
return new inter()
{
public void method()
{
system.out.println(method run);
}
}
}
}
test .funtion().method();
// inter in = test.funtion();
// in.method();
//一般都用上面那一句;