Private Java Keyword
private is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java programming language likewise the private keyword indicates the following :
-
It is used as an access control modifier.
-
It is applicable to a class, a method or a field.
-
private method or a variable is not visible outside a class or to its subclasses.
-
A private (inner) class, method or field are only referenced from within the class in which it is declared.
-
By default the access allowed for all class members is package access.
Using a private Keyword within a class
public class ClassName { private class ClassName1; } |
Declaring Private Variable
public class ClassName { private int i; } |
Declaring Private Method
public class ClassName { private String Method() { <statements> ... } } |