Forums Register Login

Usage of private access modifier

+Pie Number of slices to send: Send
according to the following source code sum and NUMBER variables are declared as private.According to my knowledge private variables can only use within class.But following program doesn't give any error.Can some one explain the reason for this .






+Pie Number of slices to send: Send
You didn't actually show us code where sum and NUMBER are being accessed outside of their declaring class' file.
+Pie Number of slices to send: Send
from call to this add method.so, add method use those sum and NUMBER parameters. Isn't it?
1
+Pie Number of slices to send: Send
No, that counts as use inside of the class in which they're declared.
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 692 times.
Similar Threads
toString
applet with NetBeans
Private variables inherited but not accessible
Manager / worker / updated data
Adding the integers of a number
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:08:58.