Private Java Keyword

private is a keyword defined in the java programming language.


 
Ads

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>
 

}

}

Advertisements

Ads
Share on Google+Share on Google+

Private Java Keyword

Posted on: November 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Private Java Keyword  

Post your Comment


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

java

Ads

 

Ads