I know that this would be bad practice although I know that I would not be able to explain why.
int [] intArr = ...
...
try{
int i = 0;
while(true){
System.out.println(intArr[i++]);
}
}catch(ArrayIndexOutOfBoundsException e){}
I think that you are only supposed to use exceptions for things that shouldn’t happen. I am asking this question because I think that I am using exceptions wrong sometimes. If your programming is running a standard case should exceptions be thrown?
This seems related:
Preventing exceptions vs. catching exceptions in Java
You are right: exceptions are meant for, ehm, exceptional cases. Using them for controlling normal control flow is not only obscuring the intent of the code (which would be enough to disqualify it already), but also is much slower, since throwing and catching exceptions is costly.
The standard idiom (in Java5 and above) is using a foreach loop: