class method with parameters

Method with parameters
1. Define a method with parameters
access modifier return value type method name (parameter) {
//method subject
}

2. Method call
①new instantiation ②Use the
object name.Method();
*Methods with parameters must assign a variable of the same type to the method

3. How miserable method
① When passing a value in a more miserable method, pay attention to the one-to-one correspondence of the value types to be passed, and separate each parameter with a comma.
② The more miserable method is defined by using an array if they are all of the same type variable.

4. Array method with parameters
In other classes, when assigning actual parameters to an array method with parameters, you can first declare a new array with the same length and type as the actual parameter, and
then assign the object name of the new array to the array with the same type. In the formal parameters of the parameter method

5. Formal participation actual parameters
①Formal parameter: the name of the parameter when the method is defined
②Actual parameter: the actual value passed to the method when calling the
method

6. Define the method:
①with no return value ②with return value
with misfortune

Package

1. Advantages
① Allow classes to be composed into smaller units (similar to folders), easy to find and use corresponding files
② Prevent naming conflicts
③ Better protection of classes, properties and methods

2. Create a package ①Create a
package with a package declaration, ending with a semicolon ②In Java, start with package ③The package name must be all lowercase ④The package name cannot start or end with a dot ⑤It is best to add a unique prefix before the package name, usually use Organize the inverted network domain name; domain name: Http//. Inversion: declare that the package name is from large to small ⑥ The package must be at the top of the source program






3. Import the package
① Use the import keyword
② must be under the package import. Package name. Class name ends with a semicolon

 

3. The prefix
of the package cn.jbit is the prefix of the package

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325224185&siteId=291194637