Can this java snippet be re-written? -
Can anyone suggest that the following java snippet has to be rewritten and if so, why it would be unfair, thanks !
Try {int i = 0; While (true) a [i ++] Func (); } Hold (ArrayIndexOutOfBoundsException E) {}
Use a loop:
Or alternatively, a simple for loop:
for (int i = 0; i & lt; a.length; i + +) {A [i] .func (); }
As a result the bytecodes are more or less similar, but I look for each loop more elegant. Your code is inappropriate, because it:
- Uses an exception for flow control
- Uses some time (true) loop (just like in some other way) Do not use it)
Comments
Post a Comment