面向对象day01
package oop;
public class Demo1 {
public static void main(String[] args) {
Demo1 demo1 = new Demo1();
System.out.println(demo1.sayHello());
System.out.println(demo1.max(2,3));
}
/*修饰符 返回值类型 方法名(...){
方法体
}*/
public String sayHello(){
return "hello world";
}
public int max(int a, int b){
return a>b ? a:b; //三元运算符
}
}
输出结果
hello world
3
浙公网安备 33010602011771号