In earlier parts, we had declared a class, added member method, member field. We created instance of our object to see how to use a java class.
In this article, we will be looking how access modifiers work.
Lets look to use of constructor in a java class.
public class servers
{
String ostype;
public servers()
{
ostype = "not provided";
}
public void addServer()
{
}
private void buildServerID()
{
}
}
In our above class, we got two function in our class. When has "public", and other got "private" access modifiers. When an object is created, function with private access modifier will not be available to use by object directly. It can be accessed by class inside.
Lets see it in Java class example.
In above example, we can access function that is public defined, but can not see private defined.