Originally posted by Abdulla Mamuwala:
I doubt if encapsulation in Java means "hiding non-essential details of an object".
"Encapsulation is the ability of an object to place a boundary around its properties (ie. data) and methods (ie. operations). "
Reference URL
Anything that is implementation and not part of the public interface of a class is "hidden" or "encapsulated" in the class in which it is defined. That is, it cannot be seen or directly used by other classes.
Originally posted by umut uzumcu:
Yes thats right about the encapsulatin. But I used private for all variables in a class and it gives me the error "Illegal start of expression" Why?
Originally posted by umut uzumcu:
Adam,
My program is working without any error. When i used private for mail programs variables it gave me error for each variable. But I can do it in other classes.
eg.
public static void main()
{
private String name;
private boolean flag=false;
}
Error :Illegal start of expression.
Originally posted by umut uzumcu:
Adam,
My program is working without any error. When i used private for mail programs variables it gave me error for each variable. But I can do it in other classes.
eg.
public static void main()
{
private String name;
private boolean flag=false;
}
Error :Illegal start of expression.
Originally posted by Jayaraman Suresh Babu:
I think thats wrong. Private members are fully accessible to all methods inside the class. However they simply not visible anywhere else.
Don't get me started about those stupid light bulbs. |