1. Launch Eclipse IDE and ensure that 'Box.java' Class file contains three instance variables as shown below:
3. Create a new class named 'DotOperatorDemo' under 'Third Project' as shown below:
7. Now assign a value to the inserted variable as shown below:
Click here to download the program which contains the DotOperatorDemo class (After download, you can import this project to Eclipse IDE installed on your machine)
Please comment below to feedback or ask questions.
As explained in this post, we've used dot (.) operator to access instance variables of a class by creating object to that class. In the same way we can access methods of the class by creating an object to it. How to access methods of a class by creating object for the class will be explained after Explaining the concept of Methods in next post.
4 comments:
Hi Arun,
Here in the above BOX and DotOperatorDemo classes are created in the same project but different packages, in this case not possible to execute the above program.so what to do?
Hi,
You have to import the Classes which are outside of your package.
Regards,
Arun Motoori
Thanks
Post a Comment