关于匿名类的描述

今早起来看到一则文章,是关于对关于匿名类的描述。但是English。翻译了一下,和大家一起学习一下,翻译不对的地方还希望各位指点。

[size=x-large][color=red]关于匿名类的描述。[/color][/size]

Anonymous inner class are local inner classes that don't have a class name.
[color=red]匿名内部类是局部的内部类,它没有名字。[/color]
You use an anonymous class when you want to create and use a class but don't
want to bother with giving it a name or using it again.
[color=red]当你想要创建并使用一个类但是你不想要因为一次又一次的命名而困惑的时候就可以使用一个匿名的类。[/color]
When use an anonymous inner class ,the keyword class is missing,and there are
[color=red]当使用一个匿名的内部类的时候,在这个类中不能有关键字,也没有[/color]
no modifers(public,protected,and so on). The kewords extends and implements are
[color=red]访问修饰符(例如public,protected,等等)。继承(extends)和实现(implements)关键字也不能有。[/color]
missing too. These keywords aren't allowed because we create anonymous inner
[color=red]这些关键字之所以不允许,是因为创建一个匿名的内部类[/color]
class through another extension to the new operator syntax. That means the complete
[color=red]是通过其它扩展性的操作语法new 对象的。也就是说完整的类的[/color]
class definition is actually part of a java expression. Right after the
[color=red]定义是真正java表达式的一部分。在实例化某个类(new someClass())语法之后,[/color]
new someClass() syntax,you write a curly brace and start to write a class definition.
[color=red]你写了一个{,然后开始写一个类的声明,这样是正确的。[/color][color=gray](curly brace 是花括号的意思。这句话的意思就是:new someClass(){Add code here};)[/color]
It's that simple.
[color=red]那是非常的简单。[/color]
The lack of a class name has a number of implications for the definition and use of
[color=red]弱的类名称有一个牵连(引用)数字指向定义并使用内部类。[/color]
inner classes.You can't define contructors for an anonymous inner class because
[color=red]你不能为一个匿名的内部类定义一个构造方法,因为[/color]
you can't name them. They must always (implicitly) extend a superclass or implements
[color=red]你不能给它们的构造方法命名。它们必须通常的(绝对地)继承一个父类或者实现[/color]
some interface,even though you never use the extends or implements keywords.
[color=red]某个接口,即使你没有使用继承或者实现关键字。[/color]

关于更多的匿名的内部类的知识,请大家参考其他人的文章。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值