方法的定义
package 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{
}
}
package oop;
public class Demo02 {
public static void main(String[] args) {
//实例化这个类 new
//对象类型 对象名 = 对象值;
Student student = new Student();
student.say();
}
//和类一起加载的
public static void a(){
// b();
}
//类实例化 之后才存在
public void b(){
}
}