aspose file tools*
The moose likes Beginning Java and the fly likes Access Specifier of class: Guidelines to share.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Access Specifier of class: Guidelines to share.." Watch "Access Specifier of class: Guidelines to share.." New topic
Author

Access Specifier of class: Guidelines to share..

Nitin Bhagwat
Ranch Hand

Joined: Sep 09, 2004
Posts: 132
I am new to Java. Some rules / guidelines i found for access specifiers for classes are as under: (Please let me know if any other you know!)

Access Specifier of class:
==========================
All these rules also applicable to subclasses.

1.public class rule:
In one Java file, there can be maximum one public class. This class must be name of that java file.
For example, in java file samplepgm.java , public class can be only "public class samplepgm{//code }"

2.private or protected class rule:
A class can be defined as private or protected only if it is inner class within another class (not a inner class defined in a method).


"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Nitin,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

We request that display names follow the patter FIRST_NAME + SPACE + LAST_NAME. Your previous display name of "Nitin Bhagwat" was fine.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
u r almost there ....just to extend to that ..... in ur 1) rule ...where u r telling about public classes ... the main method has to b there, in that class ... and hey we r missing the "default" modifier ... that means scope within the package ....


Impossible is I M Possible
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Specifier of class: Guidelines to share..