Often, you'd see the listener defined as an inline anonymous class.
通常,您会看到侦听器被定义为内嵌匿名类。
As an example, the code in Listing 1 USES an anonymous class to create a Thread Factory.
例如,清单1所示的代码使用一个匿名类创建了一个Thread Factory。
To implement this listener class, we'll code an anonymous class in the main Explorer Window.
为了实现该侦听器类,我们将在主资源管理器窗口中编码一个匿名类。
To pass this to a recursive method, the anonymous class should extend a wrapper type known to the method.
为了在递归方法中传递,匿名类应该扩展方法已知的包装器类型。
The code in Listing 1 would be much neater if the anonymous class was placed separately as an inner class.
如果这个匿名类可被作为一个内部类单独放置,那么清单1中的代码将会简洁很多。
Locals variables needed by those functions are said to "closed over" or "lifted" into the anonymous class.
那些匿名函数所需的本地变量据说被“封闭”(closedover)或“提升”(lifted)到该匿名类中。
If you add a method, all JRuby has to do is generate a new anonymous class that includes the body of that method.
如果你添加了一个方法,则所有JRuby要做的事情就是生成一个新的匿名类,该类包含了这一方法的方法体。
The closest you can come is to use a class (frequently an anonymous class) as a "holder" of a method you need to execute.
最接近的方式是利用类(经常是匿名类)作为想要执行的方法的 “holder”。
As each anonymous class has a unique name there are no issues loading it and as a result the application is updated on-the-fly.
因为每个匿名类都有一个唯一的名称,因此在加载该类是不会有问题的,而这样做的结果是,应用被实时动态地更新了。
Loosely speaking, since our anonymous class doesn't define click itself, the method lookup proceeds right to left, as declared.
大概地讲,因为我们的匿名类没有定义自己的click,所以这个方法会按照声明从右到左开始寻找。
To do this recursively, you close over the rest of the join point by encapsulating the proceed (..) call in an anonymous class.
为了实现递归,可以通过将proceed(. .)调用封装在匿名类中来隐藏连接点的其他部分。
Since the "locals" used by an asynchronous functions are actually fields on an anonymous class, they must be retained for the duration of the call.
由于在异步函数中所使用的“局部变量”实际上是某个匿名类中的字段,因此在调用期间它们必须被保留。
What's useful about this class is that you can use anonymous classes to override only the methods you want; the rest of the methods are implemented by default.
它的作用在于,您可以使用匿名类来替代您所希望替代的方法;剩下的方法会按默认方式实现。
The convert anonymous class to nested refactoring takes an anonymous class and converts it to a nested class of the method that originally contained the anonymous class.
ConvertAnonymous ClasstoNested重构能够接受一个匿名类并将其转换为最初包含这个匿名类的方法的一个嵌套类。
If this takes several seconds, which is not uncommon for an asynchronous call, the anonymous class may be inadvertently promoted to the more expensive generation 1 or 2.
如果此过程耗时数秒,这对于异步调用而言是很常见的,而该匿名类可能在不经意间被晋升为垃圾回收器中更昂贵的1代或2代对象[3]。
An anonymous class is a kind of syntactic shorthand that lets you instantiate a class implementing an abstract class or interface where you need it, without having to explicitly give it a class name.
匿名类是一种语法速写标记,使您能够在需要实现某个抽象类或者接口的地方创建一个类的实例,而不需要显式提供类的名称。
Instance initializers allow you to execute construction code for an anonymous inner class.
实例初始化器允许您为一个匿名内部类执行构造代码。
The indirection, which is based on "advanced compilation techniques (like abstract bytecode)" results in one master class and several anonymous, JIT enabled support classes.
该间接产物基于“高级编译技术(类似抽象字节码)”,会产生一个主类和几个匿名类、以及一些启用JIT的支持类。
The first set of enclosing braces delineates the construction of an anonymous inner class, and the second set delineates the instance initializer for the anonymous inner class.
第一组闭合括弧划定一个匿名内部类的构造,第二组划定匿名内部类的实例初始化语句块。
Two things are worth mentioning when considering this code: First, the instantiation of an anonymous inner callback class requires a great amount of boilerplate code.
上面的代码有两点值得我们注意:首先,匿名内部回调类的实例化需要大量的样板代码。
Here, the ActionListener implementation is defined in place, as an anonymous inner class, and directly attached to the button.
这里,ActionListener实现是适时定义的,它定义为一个匿名内部类,并直接附加到按钮上。
The only thing a class needs to be used this way is a default constructor (which allows you to create an anonymous inner class instance inheriting from your class).
惟一需要以这种方式使用一个类的是一个默认构造函数(它允许您创建继承自类的一个匿名内部类)。
I'm left with some ugly boilerplate code because of the anonymous inner class wrapping this method's real purpose - the two lines of code that appear in the body of the addOrderFrom method.
考虑到包装这个方法的匿名内部类的真正用途,我留下了几行难看的样板代码—addorderfrom方法体中的两行代码。
For example, only final object references from the outer class are invokable within the body of the anonymous inner class.
例如,在匿名内联类的主体中,只能调用外部类中的final对象引用。
Contrast this with the instance of the "StudentsFees" class, which didn't need to be referenced anywhere else in the diagram and, thus, could be anonymous.
与之相反,“StudentsFees ”类的实例不需要在图中的其它任何地方引用,因此可以是匿名的。
To verify that your new user and class of user has access to the Upload features, log out to become the anonymous user and browse a piece of content that has an attachment.
要检查新的用户能否访问upload特性,退出登录变成匿名用户,然后浏览带有附件的内容。
Now, this is a large class, and if you don't do anything about it, it can be very anonymous.
这是一门大班课程,如果你并不打算和周围人相互介绍的话,也就不会有什么人能够认识你了?
This is an improvement over having to write a class any time an anonymous inner class is needed and can help keep the code more self-documenting.
相比于每个匿名内部类都要对应一个类的做法来说,这种方式是个极大的改进,同时也使得代码的可读性更好。
The idea here is that the object behind the interaction is anonymous and any object of that class could take part in the interaction.
它的含义是,交互背后的对象是匿名的,该类的任何对象都可以参与到交互中。
So, again, I want to stress you have the option of staying anonymous in this class, but you also have the option of seeking out and making some sort of contact with us.
那么,我再强调一遍,你们可以选择在这门课上默默无闻,但是你们也可以选择站出来,跟我们多多接触。
应用推荐