Home Help Java P Private Java Keyword
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Private Java Keyword

Advertisement
private is a keyword defined in the java programming language.

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>
<statements>

...

<statements>
 

}

}

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 16, 2009

Ask Questions?    Discuss: Private Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Srishty Kaur
April 26, 2012
java

java
DMCA.com