回顾方法的定义

 1 package com.oop.Demo1;
 2 
 3 import java.io.IOException;
 4 
 5 //Demo1 类
 6 public class Demo1 {
 7     //main 方法
 8     public static void main(String[] args) {
 9 
10     }
11     /*
12     修饰符  返回值类型   方法名(...){
13         //方法体
14         return返回值;
15     }
16      */
17     //return 结束方法,返回一个结果!
18     public String sayHello(){
19         return "hello,world";
20     }
21     public void print(){
22         return;
23     }
24     public int max(int a,int b){
25         return a>b ? a : b;//三元运算符!
26     }
27     //数组下标越界:Arrayindexoutofbounds
28     public void readFile(String file) throws IOException{
29         
30     }
31 }

 

posted @ 2021-05-02 20:52  HeartlessHero  阅读(49)  评论(0)    收藏  举报