Java review method and deepen-13 days study notes

Method definition

  • Modifier
//Demo01   就表示类
public class Demo01
{
    
    
		//main 方法
		public static void main (String []args){
    
    
				
		}
		
		/*修饰符 返回值类型 方法名 (方法参数){
				方法体
				return 返回值;
		}
		   return 结束方法返回一个值
		*/
		public  String seeHello (){
    
    
		    return "hello";
		}
		//还有返回空的值void
		public static void hello(){
    
    
				
				//也可以写return;
		}
		//(int a, int b)形式参数并没有参加运算
		public int max (int a,int b){
    
    //比大小
				return a>b ? a : b;  //三元运算符
		}
}

  • Return type
  • break: Jump out of the loop and end the loop and return the difference between return value
  • Method name pay attention to standard hump nomenclature see the meaning of the name
  • Parameter list (parameter type parameter name) …variable parameter.
  • Exception thrown

Method call

  • Static method
  • Non-static method
  • Formal and actual parameters
  • Pass by value and pass by reference
  • this keyword

Guess you like

Origin blog.csdn.net/yibai_/article/details/114768165