my goal here is to create a new array from the old array according to a Criteria that i set (all numbers above 100 and even)..
however the program gives me 2 mistakes, and i dont know why?
public class Array {
public static void main(String[] args){
Manipulate manipulate=new Manipulate(); //mistake here
int[] numbers={123,213,1234,45,123,124,11,2,34};
manipulate.manipulate(numbers,new Data()); // mistake here
for (int i : numbers) {
System.out.println(i);
}
}
class Manipulate{
public void manipulate(int[] values, Criterion function){ // does function refers first to the interface and then to the Data class when i call new Data()?
for(int i=0;i<values.length;i++){
values[i]=function.func(values[i]); // do those values go there after i call a method from class data ?
}
}
}
interface Criterion{
int func(int num);
}
class Data implements Criterion{
@Override
public int func(int num) {
if (num>100 && num%2==0)
return num;
return num;
}
}
}