Jayakrishnan.C Chandramohan wrote:Hi all,
can i declare a class as a private???
private class A
public static void main(Strings g)
You cannot declare top level classes as private . Inner classes however can be private.
Why do you want to make your class private? If you want the class to be only visible within a package, then you can use package visibility: Just declare the class without an access modifier.
Hence, your code will result in error and cannot be compiled.
EDIT: import corrected instead of include.
By include, do you mean import? Include is not a Java keyword; are you thinking of C++? As D. Ogranos has already said, inner classes may be private or protected.
Kemal Sokolovic wrote:There are only two access modifiers allowed for classes - public (class can be accessed from anywhere as long as you put include if neccessary) and default
. . .