Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anonymous Objects in Java

Tags:

java

Java helps us creating anonymous object using

new class_name();

statement and calling the methods using association(.) operator like

new Emp().input();

How can I use it to invoke two methods simultaneously from an anonymous object like invoking both input() and show() together ?

like image 794
pnkjshrm30 Avatar asked Jul 23 '14 17:07

pnkjshrm30


1 Answers

or

public Emp show() {
    // do the stuff
    return this;
}
public Emp input() {
    // do the stuff
    return this;
}

Then call with

new Emp().show().input();
like image 109
Sebas Avatar answered Nov 07 '22 05:11

Sebas