Programming Meme
Eric Florenzano started a fun programming meme over at his blog, and I thought I'd join the fun. I'm planning to get a G1 phone sometime early next year, so I thought it would be a good time for an initial foray into Java since I plan to create custom Android applications in the future.
This is the first program I've ever written in Java, so I'm sure it's a mess in many ways I don't yet understand. One thing I found very telling is the amount of code to implement this compared to the amount of code needed in Python. I understand Java was never meant to be a command-line scripting language, however, so I'm giving it the benefit of the doubt and assuming that's why it took so much to get so little. . .
So, without further ado, I present to you Eric Florenzano's programming meme in Java:
import java.io.*; class ProgrammingMeme { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String name = null; String ageStr = null; System.out.print("Please enter your name: "); try { name = br.readLine(); } catch (IOException ioe) { System.exit(1); } System.out.print("Please enter your age: "); try { ageStr = br.readLine(); } catch (IOException ioe) { System.exit(1); } int age = Integer.parseInt(ageStr); for (int i = 0; i < age; i++) { System.out.println(i + ") Hello, " + name); } } }
Please critique using the comments below.
And, since I jokingly called out Camron Flanders because he listed everyone else's contribution and not mine and then he actually added me, here's a link to Camron's Ruby contribution to the meme. Thanks, Camron!
Comments
Brandon Konkle
I've been creating websites for over 10 years, and I've been using Django since early 2008. I focus on high quality, well-tested, maintainable code and reliable high-performance deployments. Web development is something that I am very excited about, and I love finding elegant and innovative ways to push web applications further.