what is the use of making a variable public.
After all the client is provided only with the .exe code
So now whats the actual use of maling a variable private?
asterix15
0
Newbie Poster
Recommended Answers
Jump to Post.exe code?
…
you declare a variable as private to increase encapsulation. also, this makes sure you control how other classes can access the value of the variable. when they're marked private, the value of the variable can only be changed or gotten through the use of methods (setters and getters).
Jump to Postit's more about making sure the code using the class gets the correct values returned from methods, and such.
you can always declare your variables public, but this will lower the security you have that everything will "work as planned".
you can design your program as carefully as …
All 7 Replies
stultuske
1,116
Posting Maven
Featured Poster
asterix15
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.