fork download
  1. /* The class name doesn't have to be Main, as long as the class is not public. */
  2. class Main
  3. {
  4.  
  5. public static void main (String[] args)
  6. {
  7. System.out.println("Hello world!");
  8.  
  9. if (2 < 3)
  10. {
  11. System.out.println("2 is less than 3");
  12. }
  13. else
  14. {
  15. System.out.println("2 is NOT less than 3");
  16. }
  17.  
  18. for (int n = 0; n <= 3; n++)
  19. {
  20. double nSquared = Math.pow(n, 2);
  21. String myMessage = "The number " + n + " squared is " + nSquared;
  22. System.out.println( myMessage );
  23. }
  24.  
  25. }
  26.  
  27. }
Success #stdin #stdout 0.1s 213376KB
stdin
Standard input is empty
stdout
Hello world!
2 is less than 3
The number 0 squared is 0.0
The number 1 squared is 1.0
The number 2 squared is 4.0
The number 3 squared is 9.0