Stefan Roock

All About Agile and Lean

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];
}

Published by

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit deinem WordPress.com-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

%d Bloggern gefällt das: