How can improve this algorithm in order to use a dynamic validation source?
public static void main(String[] args)
{
int[] exclude = {1, 4, 7};
for(int i= 0 ; i < 10; i++)
{
if(i != 1 || i != 4 || i != 7);
{
continue;
}
}
System.out.println(i);
}
}
Meaning, I want to instead of the if
inside the for
loop, I want to receive a list and validate the content of must-exclude elements, maybe something like:
if(Arrays.asList(exclude).contains(i))
Just for the sake of knowing how to do it. I feel like it might potentially be useful in the future. Basically I want to skip certain iterations in a loop using an array.
How