Day08

方法

package oop;
//Demo01 类
public class Demo01 {
    public static void main(String[] args) {

    }
    /*
    修饰符 返回值类型 方法名(。。。。){
            /方法体
            return 返回值
            }
     */
    public String sayHello(){
        return "hello,world!";
    }
    public int max(int a,int b){
        return a>b ? a : b;
    }
}

方法的调用

  • 静态方法
  • 非静态方法
  • 形参和实参
  • 值传递和引用传递
  • this关键字
package oop;

public class Demo02 {
    //静态方法 static
    /*
       类名.方法名
     */
    //非静态方法
    /*
     实例化这个类  new
     对象类型   对象名   = 对象值
     例:Student student = new Student();
     */



    //和类一起加载的
    public static void a(){
        ~~b();~~
    }
    //实例化之后才存在
    public void b(){

    }
}

posted @ 2020-10-01 15:13  JWEY  阅读(65)  评论(0)    收藏  举报