Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yea, the advantage of Java over C is the second program.

for (int x = 1; x <= 100; x++){ System.out.println("Hello World! " + x); }

vs

for (int x = 1; x <= 100; x++){ printf("Hello World! %d! \n", x);

PS: How do you include readable code snippets on HN?



    Prefix four spaces to a line to format code.  
Also, you're missing a right curly brace in the second example.


Perl:

  for (1 .. 100) print "Hello World! $_\n";
Ruby:

  100.times { |i| puts "Hello World #{i}" }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: