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


 
 

Share on Google+Share on Google+

Public Java Keyword

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

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

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: Public Java Keyword  

Post your Comment


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

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

can we use public(java keyword) in interface?
DMCA.com