1. 枚举类
跳了很多。。。
2. 注解
3. 作业
1. 注意:所有类共享静态属性
所以结果是 9,red 100,red
package com.zsq.homework1;
public class HM1 {
public static void main(String[] args) {
Cellphone cellphone = new Cellphone();
cellphone.testWork(new Calculate() {
@Override
public double work(double n1, double n2) {
return n1+n2;
}
},100, 200);
}
}
interface Calculate{
public double work(double n1, double n2);
}
class Cellphone{
public void testWork(Calculate calculate, double n1, double n2){
double result = calculate.work(n1, n2);
System.out.println("结果是" + result);
}
}