Java中的匿名对象 [英] Anonymous Objects in Java
本文介绍了Java中的匿名对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java帮助我们使用
Java helps us creating anonymous object using
new class_name();
语句并使用关联(。)运算符调用方法
statement and calling the methods using association(.) operator like
new Emp().input();
如何使用它从匿名对象同时调用两个方法,如同时调用 input()
和 show()
在一起?
How can I use it to invoke two methods simultaneously from an anonymous object like invoking both input()
and show()
together ?
推荐答案
或
public Emp show() {
// do the stuff
return this;
}
public Emp input() {
// do the stuff
return this;
}
然后拨打电话
new Emp().show().input();
这篇关于Java中的匿名对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文