//Demo01类
public class Demo01 {
//Demo01类里面的main()方法 用于启动程序(一个真正的程序中只有一个main方法)
public static void main(String[] args) {
//System.out.println("Hello World !");
new Demo01().sayHello();
System.out.println(new Demo01().sayHello());
Demo01 demo01 = new Demo01();
demo01.sayHello();
System.out.println(demo01.sayHello());
}
/*
* 修饰符 返回值类型 方法名(形式参数){
* 方法体
* return 返回值;
* }
* */
public String sayHello() { //public 表示公开,任何人都能访问
return "Hello World1 !";// 返回值的类型要和要求的返回值类型对应
}
//没有返回值
public void hello() {
return;//表示返回空
//或者不写。
}
public int max(int a,int b){
return a > b ? a : b;//三元运算符
}
//数组下标越界异常:Arrayindexoutofbounds
//读文件会抛出异常
/**
*
* @param file
* @throws IOException
*/
public void readFile(String file) throws IOException{
}
}