Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Public Java Keyword

public is a keyword defined in the java programming language.

Ads

Public Java Keyword

     

public 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 public keyword indicates the following :  

--  It  is used as an access control modifier.
--  It is applicable to a class, a method or a field.  
--   public class, method or a variable are visible to all the classes defined in different package.
--   A public class, method or field can be referenced from outside the class in which it is declared. 

Using a public Keyword within a class

public class ClassName{

public class ClassName1;

}

Declaring public Variable

public class ClassName

{

public class ClassName1;

public int i;

}

Declaring public Method

public class ClassName{
public String Method(){
<statements>
<statements>
...

<statements>
}

}

Advertisements

Share on Google+Share on Google+

Public 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

Ads
 

Discuss: Public Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
souvik
June 18, 2011
java

what is tha use of super!
sujitha
November 24, 2011
java

can we use public(java keyword) in interface?

Ads

 

Ads