当前位置:网站首页>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
边栏推荐
- A real day for Beijing programmers!!!!!
- You Li takes you to talk about C language 7 (define constants and macros)
- Uncover the seven quirky brain circuits necessary for technology leaders
- Introduction to RT thread kernel (4) -- clock management
- Function (basic: parameter, return value)
- 如何优雅的获取每个分组的前几条数据
- [phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
- Sword finger offer 07 Rebuild binary tree
- [popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
- FFmepg使用指南
猜你喜欢

TPG x AIDU | AI leading talent recruitment plan in progress!

Managed service network: application architecture evolution in the cloud native Era

揭秘技术 Leader 必备的七大清奇脑回路

【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录

What are the building energy-saving software
![[phantom engine UE] package error appears! Solutions to findpin errors](/img/d5/6747e20da6a8a4ca461094bd27bbf0.png)
[phantom engine UE] package error appears! Solutions to findpin errors

Rome chain analysis

Threejs realizes the drawing of the earth, geographical location annotation, longitude and latitude conversion of world coordinates threejs coordinates

CSDN正文自动生成目录

假设检验——《概率论与数理统计》第八章学习笔记
随机推荐
【科普】热设计基础知识:5G光器件之散热分析
2022-2028 global and Chinese equipment as a Service Market Research Report
如何优雅的获取每个分组的前几条数据
Learning MVVM notes (1)
CSDN正文自动生成目录
Practice | mobile end practice
Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
Open graph protocol
Threejs rendering obj+mtl model source code, 3D factory model
函数(易错)
【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
Discussion on the dimension of confrontation subspace
Mixed compilation of C and CC
How to remove installed elpa package
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
Introduction to RT thread kernel (5) -- memory management
Neural networks and deep learning Chapter 6: Circular neural networks reading questions
The development of mobile IM based on TCP still needs to keep the heartbeat alive
3 minutes learn to create Google account and email detailed tutorial!
PHP读取ini文件并修改内容写入