Page 1 of 1
Private variables!?
Posted: Sat Feb 21, 2015 7:16 pm
by Bencratus
Hello,
If I use in only one class e.g. int x = 0; better make private int x = 0; ? Or this doesn't matter?
Thanks,
Bencratus
Re: Private variables!?
Posted: Sat Feb 21, 2015 7:52 pm
by canislupus
public modifier—the field is accessible from all classes.
private modifier—the field is accessible only within its own class.
http://docs.oracle.com/javase/tutorial/ ... ables.html
Re: Private variables!?
Posted: Sat Feb 21, 2015 8:26 pm
by Bencratus
Seems you didn't read everything or you don't understand. I don't even talked about public variable, but you posted what you found on google.
Nevermind

Re: Private variables!?
Posted: Sat Feb 21, 2015 9:55 pm
by Zoey76
How is this relevant to High Five support?
Our standards say that we should use the smallest scope for the variable.
So private is better than default (without any keyword).
Re: Private variables!?
Posted: Sat Feb 21, 2015 10:09 pm
by Bencratus
Zoey76 wrote:How is this relevant to High Five support?
Our standards say that we should use the smallest scope for the variable.
So private is better than default (without any keyword).
Sorry for wrong place...
Thanks, I will change now all to private

Re: Private variables!?
Posted: Sun Feb 22, 2015 3:25 am
by canislupus
Hi,
Why isn't it relevant? public would be the opposite of private am i right?
Bencratus wrote:
Seems you didn't read everything or you don't understand. I don't even talked about public variable, but you posted what you found on google.
Nevermind

Hey ! The intention is what truly matters!

Re: Private variables!?
Posted: Sun Feb 22, 2015 6:59 am
by Zoey76
canislupus wrote:Why isn't it relevant?
It's not relevant to High Five support, is a general coding question.
Re: Private variables!?
Posted: Sun Feb 22, 2015 7:17 pm
by canislupus
Oh i meant about my reply, since he didn't like it.
If it doesn't belong to the section then you must be right