当前位置:网站首页>Scope of package class package
Scope of package class package
2022-07-05 04:28:00 【Blue dye k9z】
package
- Java Allow the use of packages (package) Organize classes .
- With the help of packages, you can easily organize your own code , And compare your own code with the code base provided by others Separate management .
- The standard Java Class libraries are distributed in multiple packages , Include java.lang、java.util、java.net etc.
- The standard Java Packages have a hierarchy , It's like a directory nesting on a hard disk , You can also use nested hierarchies to organize packages .
- All standard Java The bags are all in java and javax In the package hierarchy .
- Main of using package reason Is to ensure the uniqueness of the class name .
- Suppose two programmers have established Employee class , Just put these classes in different packages , There will be no Conflict .
- From the compiler's point of view , There is no relationship between nested packages .
- Such as ,java.util Bag and java.util.jar The bag has nothing to do with it .
- Each has a separate set of classes .
Class import
- A class can use all the classes in its package , And other public classes in the package (public class).
- There are two ways to access public classes in another package .
- Add the full package name before each class name , Such as
java.time.LocalDate today = java.time.LocalDate.now();
- A simpler and more common way is to use import sentence ,import A statement is a concise description that refers to a class contained in a package , Used import After statement , When using classes , You don't have to write the full name of the package .
import java.util.*; LocalDate today = LocalDate.now();
- Add the full package name before each class name , Such as
- Only one package can be imported with an asterisk , Out of commission
import java.*
orimport java.*.*;
Import to java All packages for prefix .
Packet scope
- public Can be used by any class ;private Parts of can only be used by the classes that define them
- If not specified public or private, This part ( class 、 Method or variable ) Can be accessed by all methods in the same package
边栏推荐
- Possible stack order of stack order with length n
- [uniapp] system hot update implementation ideas
- Behavior perception system
- Uncover the seven quirky brain circuits necessary for technology leaders
- Power management bus (pmbus)
- How can CIOs use business analysis to build business value?
- Judge whether the stack order is reasonable according to the stack order
- Ctfshow 2022 Spring Festival welcome (detailed commentary)
- [untitled]
- MySQL: view with subquery in the from clause limit
猜你喜欢
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
Discussion on the dimension of confrontation subspace
Raki's notes on reading paper: code and named entity recognition in stackoverflow
Burpsuite grabs app packets
NetSetMan pro (IP fast switching tool) official Chinese version v5.1.0 | computer IP switching software download
2022-2028 global and Chinese equipment as a Service Market Research Report
mysql的七种join连接查询
【虚幻引擎UE】实现UE5像素流部署仅需六步操作少走弯路!(4.26和4.27原理类似)
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
【FineBI】使用FineBI制作自定义地图过程
随机推荐
PR video clip (project packaging)
直播预告 | 容器服务 ACK 弹性预测最佳实践
Label exchange experiment
2022-2028 global and Chinese FPGA prototype system Market Research Report
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
Sequence diagram of single sign on Certification Center
函数(基本:参数,返回值)
kubernetes集群之调度系统
Burpsuite grabs app packets
A application wakes up B should be a fast method
[phantom engine UE] realize the animation production of mapping tripod deployment
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
Threejs Internet of things, 3D visualization of farms (I)
MacBook installation postgresql+postgis
指针函数(基础)
Basic analysis of IIC SPI protocol
Function (error prone)
线上故障突突突?如何紧急诊断、排查与恢复
SPI read / write flash principle + complete code
Pointer function (basic)