Do You Speak Java?

April 21, 2004 at 6:38 am Leave a comment


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

Entry filed under: Uncategorized. Tags: .

Article Directory about Agile Methods JUnit speaks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed



%d bloggers like this: