Is it possible to have class A with an empty method say render().. then you create 3 instances of the class, so you have objects b, c, d, so can I THEN assign bodies for the render method for each object?
Here’s an example, in JavaScript you can have an object say a and then anywhere you can say
a.method = function() { /* do something */ }
After that line, you will have a method with the name method for the object a and whenever called it will /* do something */.
Is this possible in Java and what is the syntax?
My idea is to have a button class and assign different actions to it’s instance’s click method inside the different situations / context it is used, so I don’t have to define a different child class for each action.
You can annomyously instantiate a subclass of the
Aclass and override the method you’d like in it. Like so