1: Package and access rights
To place a class in a package, you need to use the package name
The use of the-d parameter at compile time the function of this parameter is to generate the corresponding folder according to the package name
The whole of a class should be "package name" + "." + "class name"
Naming conventions for package names:
Require that all letters of the package name be lowercase
Package name in general, is your domain name upside down write
A class in a package accesses the conditions of a class in another package
1: I'll make a bag.
1: Access class Import Package name
2: The accessed class must be public
Under the above conditions: if you want a class to access the properties and methods of another class, they must be public
Public own packages and other classes in the package can be accessed
private only their own classes can access the
(default) your own package can be accessed,
protected can only modify variables and methods and be accessible only by its subclasses outside the package.
2: interface
Defining an interface is equivalent to defining the criteria for calling an object
Basic syntax for interfaces
1: Using interface definition
2: The methods in the interface are abstract methods
3: The methods in the interface are public permissions
4: Implement interface using implements keyword
5: A class can implement multiple interfaces
6: An interface can inherit multiple interfaces
The path to Java Learning (vi)