DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chris has posted 1 posts at DZone. View Full User Profile

How To Eat An Elephant In Java

  • submit to reddit
        How do you eat an elephant? Well, 'bite by bite', they told me. In Java, this may look like this:

  Elephant elephant = ...; // get the elephant from somewhere

  while (!elephant.isEatenCompletely()) {

Why am I writing this? Well, simply to test my dzone account ;)    


Snippets Manager replied on Wed, 2007/05/16 - 10:08pm

Haha, when I read the OP I was thinking something like: elephant.bite! until elephant.eaten? You guys are silly.

Snippets Manager replied on Tue, 2008/03/04 - 11:34am

Proof that Ruby > Java: elephant.bites.each do { |bite|! } elephant.each_bite do { |bite|! } &:eat! elephant.have_one_bite until elephant.bites.empty? Should I go on...?