Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Extension Method of Java
WhatsApp
Gagan Bansal
5y
11.2
k
0
0
25
Blog
Extension Method of Java
Hello Friends
Here is the example
interface
MyInterface {
String enter(String name);
default
String exit(String name) {
return
“ Hello” + name + ”, you are using exit method of MyInterface
interface
”;
}
}
public
class
MyClass {
public
static
void
main(String[] args) {
MyInterface f1 =
new
MyInterface() {
@Override
public
String enter(String name) {
return
“ Hello” + name + ”, you are using enter method of MyInterface
interface
”;
}
};
System.out.println(f1.enter(“Aman”));
System.out.println(f1.exit(“Aman”));
}
}
Output
Hello Aman, you are using the enter method of MyInterface interface.
Hello Aman, you are using exit method of MyInterface interface
Extension Methods of Java
Up Next
Implementation Of Remote Method Invocation Concept In Java
Ebook Download
View all
Programming in Java
Read by 636 people
Download Now!
Learn
View all
Membership not found