02 回顾方法的定义

回顾方法的定义

image

代码

package com.zhan;

import java.io.IOException;

public class base05Oop {

    // 回顾方法
    public static void main(String[] args) {

    }

    /*
    修饰符   返回值类型(void)  方法名(参数){
             方法体
             return 返回值;  (return;)
    }
   */
    public static String sayHello(){
        return "hello world";
    }

    public static void sayhello01(){
        System.out.println("hello world");
        return;
    }

    // 异常
    // 比如数组下标越界 arrayindexoutofbounds
    public void readFile(String flie) throws IOException{
        
    }
}
posted @ 2023-01-27 22:45  被占用的小海海  阅读(16)  评论(0)    收藏  举报