Java – the difference between classes and packages

What is the difference between classes and packages in Java?

Solution

Class is a declaration (usually an implementation), where encapsulates are the member properties and methods owned by the type instance You can create an instance of a class as a single object with a different behavior than specified

Package is just a namespace under which you can classify classes, similar to "folder" or "path", so you can group classes with related purposes or functions

Don't be confused by the fact that Java has classes that represent the concepts of class and package. These classes are useful for checking the structure of Java programs at run time They are merely models of the above general concepts

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>