library class in java

gudii9
gudii9 used Ask the Experts™
on
Hi,

I was reading as below

All the library classes are organized in several packages. For a class to use such
library classes, it needs to import them using the import statement


Using packages provides access control to classes.

I would like to know what it means by library class. How library class is different from regular java class(with or without main statement).

How access control is provided by packages?

Please advise
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Java Architect
Commented:
There is no difference between a "library" class and a "regular" class. The text you quoted is just referring to classes that are part of a library.

Packages can provide access control in the case of protected or package-private methods and variables. Protected members can be accessed by anything that extends the current class or any other class in the same package. Package-private members can be accessed only by other classes in the same package.

By the way,

For a class to use such library classes, it needs to import them using the import statement.

This isn't exactly true. You don't have to import a class in order to use it; you can fully qualify a class name (such as java.util.Collection) and use it just fine, without importing it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial