1. Method: The method is to wrap up a piece of code, give this piece of code by the last name. When you use this code, call the name.
1. The method must be applied in the class
2. Methods in addition to methods and classes, and other how to write it.
3. Methods can call "Learn Java, to the Kaige123.com" other methods, but cannot call each other, there will be a method nested call overflow error "Java.lang.StackOverflowError"
4. Passed primarily by value (base data type) and by reference. 650) this.width=650; "Src=" http://os78f4hny.bkt.clouddn.com/201707260012.jpg?imageMogr2/blur/1x0/quality/ 75%7cwatermark/1/image/ahr0cdovl29znzhmnghues5ia3quy2xvdwrkbi5jb20vd2f0zxjtyxjrlnbuzw==/dissolve/50/gravity/ Southeast/dx/10/dy/10%7cimageslim "alt=" image "Style=" Border-style:none;background-color:rgb (255,255,255); "/>
5. Set parameter a data type plus three points plus a variable name static void A1 (INT...B) {} and static void A2 (int[] b) {} This is actually the same as the meaning. A1 (New int[] {123,456,798}); A2 (123,456,789);
6. Method overloads the method name as a different parameter type for multiple methods. is called method overloading. It invokes the method of the corresponding parameter type according to the different types of arguments given. For example: public class Test6 {
static void method (Int a) {system.out.println ("int");} Static void method (Byte a) {system.out.println ("byte");} Static void method (Short a) {system.out.println ("Short");} Static void method (Float a) {system.out.println ("float");} Static void method (Double a) {system.out.println ("Double");} Static void method (Char a) {system.out.println ("char");} Public static void main (String[] args) {byte b = 100;method (' A ');}
}
6. method returns the value returned when the method is finished executing. Only one data type can be returned. Keyword: return; In a method that has no return value, is the meaning of the end method. In the method that has the return value is the end and return the value out of the meaning. For example: static int A1 () {
return 0; The return value type is int type, and return goes out with a value of zero. 6. Method recursion is a self-nesting "learning Java, to the Kaige123.com Academy" algorithm. For example, find a folder or find files, open a clip and a clip, and open a clip, know to find the desired file. For example: static int method (int i) {if (i = = 1) {return 1;} return i + Method (i-1),} i equals 1, equals 1 returns 1. Not equal to 1 Reyurn i+ call own method (i-1). The parameters given are I minus 1. Always loop down to know I equals 1. Then return the value on a layer of layer. Method (3); Return i + method (3-1); 3+3 return i + method (2-1); 2+1 up the result equals 6.
-java Basics-Methods