What is interface in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is interface in java?

Please any help me to get this concept correctly and plse if anyone can help me with code it will helpful for me

28th Aug 2018, 2:58 AM
Devang Patel
Devang Patel - avatar
3 Answers
+ 5
Try the Java Course. I never tried it but it might be in there.
28th Aug 2018, 3:16 AM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 1
Like a user interface, or any other kind of interface, it is a way to communicate how to interact with your object. In one of the posts NimWing Yuan shared, it said it's like a 'contract'. In OOP it's very important to decouple what an object does with how it does it. The interface specifies what something does. The classes that implement the interface may all operate differently but achieve the correct goal as specified by the interface for the task at hand. https://code.sololearn.com/cop6od6LxalY/?ref=app This is a code I made where I did just that - many of the objects are defined first as an interface. The main code interacts with the interface, having no idea what the object does (because several subclasses do different things, and it doesn't know which class will be used until runtime). But it knows what an object is able to do, and can call on the interface methods
28th Aug 2018, 6:37 AM
Dan Walker
Dan Walker - avatar