回顾方法的定义


回顾方法及加深

package zaiyang.oop;

import java.io.IOException;

//Demo01 类
public class Demo01 {

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

    }


    /*
    修饰符 返回方法类型 方法名 (。。。){
    //方法体
    return 返回值;
    }
     */
    //return 结束方法, 返回一个结果!
    public String sayHello(){
        return "hello,world";
    }
    public void print(){
        return;
    }
    public int max(int a, int b){
        return a>b ? a : b; //三元运算符!
    }

    //数组下标越界:Arrayindexoutofbounds
    public void readFile(String file) throws IOException {

    }
}

相关