A method can return any type of data, including the objects.
In the following program, the incrByTen( ) method returns an object in which the value of variable a is ten greater than it is in the invoking object.
public ClassName MethodName( )
Lets implement this on Eclipse IDE:
1. Launch Eclipse IDE, Create a new Java Class 'Seventh Project, Create 'Test' class as shown below:
12. Save and Run the 'ReceiveObjects' class as shown below:
Click here to download the project containing 'Test' and 'ReceiveObjects' class files used in this post (You can download the project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
'Recursion' concept will be explained in next post.