fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // give s the value 0
  13. int s = 0;
  14. // give k the value 1
  15. int k = 1;
  16. // repeat the two statements while k
  17. // <
  18. // 5:
  19. while (k < 5){
  20. s = s+k;
  21. k++;
  22.  
  23. }
  24. System.out.println("s = " + s);
  25. // replace the value of s with s+k
  26. // replace the value of k with k+1
  27. // print s
  28.  
  29. }
  30. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
s = 10