Java Public Keyword

Java Public Keyword


Public Keyword In Java
 
The Public is an access modifier hence we can use it to make a class, attribute, method, etc Public.
A Public keyword is used when we want to make something only accessible data of one package into another package.
 
The public is a reserved word hence it will always be written in lower case.
Now we will see an example - 
 
Example 1 - In this example, we will use data of the second package in the first package.
 
 
Using this package data into our primary package
 
 
Output -