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

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -