package demo01;
public interface InterFaceB {
int getMax(int[] num);
}
package demo01;
public class Max implements InterFaceB{
//获取最大值
@Override
public int getMax(int[] num) {
int max=num[0];
for (int i = 0; i < num.length; i++) {
if (max<num[i]) {
max=num[i];
}
}
return max;
}
}
package demo01;
public class Realize {
private Max max;
public Realize(Max max) {
super();
this.max = max;
}
public int ceshi(int[] num) {
return max.getMax(num);
}
}
package demo01;
public class Test {
public static void main(String[] args) {
Realize realize=new Realize(new Max());
int[] num= {34,6,45,4545,22,3,3};
int max=realize.ceshi(num);
System.out.println(max);
}
}
package demo01;public interface InterFaceB { int getMax(int[] num);}package demo01;public class Max implements InterFaceB{ //获取最大值 @Override public int getMax(int[] num) { int max=num[