package
The main function of the Java package:
- Distinguish classes of the same name
- Classify and manage classes
a: Divide by function - organize classes or interfaces with similar or related functions in the same package
b: Divide by module - package statement
必须在文件中的第一条有效语句
, and a java file只能有一个
package - There is no #include keyword in java
- The package is composed of a set of classes and interfaces (a bit confused)
improt guide package
improt java.util.*;
- In Java, java.util.* can access util under
所有工具类
but不能访问其子目录下的类
why
- If there is a class a in java.util and a class a in java.util.list, if we want to call the methods or properties of class a, which class a should be used.
避免类名混淆
, Which is also the reason to use the package
Parameter passing
Parameter passing in Java is divided into two categories
- One is value pass
- One is pass by reference
值传递
: It means that the function will be added 实际参数复制一份传递
to the function when the function is called, so that if the parameter is modified in the function, it will be changed 不会影响到实际参数
.
引用传递
:It means that when the function is called 实际参数的地址传递到函数
, the modification of the parameter in the function will affect the actual parameter.
When the method is executed, if the basic type parameters such as int String are passed (the passed is a string), these
are passed by value, but they are 复制了参数的数值
put in the method and will not change the value of the parameter.
If the object is passed in, it is put 对象的地址传入
into the method when the method is called . Modifying the object in the method will affect the original object.
However, if the object is in the method, 重新覆盖
the address of the object is changed at this time, so the original method has no effect