Skip to content
Snippets Groups Projects
Commit e6204a26 authored by VIGNESH VIJAYAKUMAR's avatar VIGNESH VIJAYAKUMAR
Browse files

Static class

parent 1105d8df
No related branches found
No related tags found
No related merge requests found
public class Staticcls{
public static void main(String[] args){
Stat statObj = new Stat();
statObj.prin();
}
}
class Stat{//here private class Stat{} is not allowed (protected and static also)
public void prin(){
System.out.println("This is inside prin.....!");
}
}
/*>>in a single java file there should be one public class
>>above package-private class is access by creating obj
>>we cannot declare a top-level class as private or protected we need to keep
public those top-level class if you want to set a class private or protected
we need to keep those in inner class.
>>other than main public class , all other must be pacakge private and may be
private or protected if they are nested class.
*/
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment