+ 1
What is the difference between default and private in Java please ?
8 Answers
+ 7
private and default are access specifiers for declaring method..
default is user friendly and has access to only classes in package
private has minimum access only to the class it self.
+ 4
I am putting an short example that would clear you doubts
C++
class point2d {
private:
int x;
int y;
public:
void set (int a, int b) {
x=a;
y=b;
}
void plot (){
cout <<x << ", "<<y;
}
}
Java
class point2d {
private int x;
private int y;
public void set (int a, int b) {
x=a;
y=b;
}
public void plot (){
cout <<x << ", "<<y;
}
}
In C++, private and public are the sections of class definition, whereas, in Java, these are placed before each member of the class.
+ 1
Now I see the concept dude ! Break a leg for you !
+ 1
aah yeah sorry , hahah
0
This helped me a lot ! Thanks man !!!
0
aah yeaah I see ! Thank you !