fork download
  1. class Main {
  2. public static void printNumbers(int lastNumber) {
  3. var i = 1;
  4.  
  5. while (i <= lastNumber) {
  6. System.out.println(i);
  7. i++; // увеличиваем значение i на 1
  8. }
  9.  
  10. System.out.println("finished!");
  11. }
  12. public static void main(String[] args) {
  13. Main.printNumbers(5);
  14. }
  15. }
Success #stdin #stdout 0.08s 54532KB
stdin
Standard input is empty
stdout
1
2
3
4
5
finished!