I have seen the class with public or without modifiers and method with public, protected or private modifiers. I am confused how to decide modifiers for a class?
What is difference between class modifiers and member modifiers?
Printable View
I have seen the class with public or without modifiers and method with public, protected or private modifiers. I am confused how to decide modifiers for a class?
What is difference between class modifiers and member modifiers?
class modifiers are public,final,static(inner classes),abstract,default.
method modifiers public,private,protected,static,abstract,final
In classes there are two types one is top level and inner level.
For the top level class only five modifiers are allowed i.e. public, default, final, abstract, strictfp. Other than this modifiers are not allowed.
But for the inner classes public, private,protected, default, final, abstrct,strictfp,synchronized,static, and some other are applicable.