jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Using Other class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using Other class" Watch "Using Other class" New topic

Using Other class

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
when should we do and what is the diff
public class A
public class B;
public class A
private class B;
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

The public classes in a package are intended to be used by classes in other packages. The non-public classes are not. Similarly, public nested classes are intended for use by code in other packages, while private nested classes are intended to be used only by the containing class.
The "used by code in other packages" stuff might be slightly confusing; if you're used to thinking of student programs that consist of only one class, it's meaningless. But "real" software often contains thousands of classes; structuring them into packages makes the program comprehensible, and hiding most of the classes as non-public classes makes the relationships between the packages much clearer.

[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Also, aakash, you might want to take a look at Sun's Java Tutorial on Access Control.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link: http://aspose.com/file-tools
subject: Using Other class
It's not a secret anymore!