+ 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
3 Respostas
+ 12
Devang Patel : Here some information about interface in java : 💖
https://www.sololearn.com/discuss/1354577/?ref=app
https://www.sololearn.com/discuss/1211926/?ref=app
https://www.sololearn.com/discuss/676067/?ref=app
+ 5
Try the Java Course. I never tried it but it might be in there.
+ 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