Mittwoch, April 21, 2004

Do You Speak Java?

Here is a code snippet I found somewhere. Can you figure out what it does? Try code reading first and if that doesn't work, write a unit test. Is there a way to refactor the code to be more readable without loosing performance?

public int doSomething ( final int v[] ) {
int i = 0, j = v.length - 1;
for ( ; !( v[i] >= v[j--] && i++ == ++j ); );
return v[j];
}

Post bewerten

Keine Kommentare: