Hi all,
I was just wondering if anyone could explain why my function prints 5 times.
My understanding is that the loop would stop before index 5 because of the for loop condition i<5.
Would anyone please explain this to me?
Thanks 😀
package com.codegym.task.task02.task0201;
/*
Implement the print method
*/
public class Solution {
public static void main(String[] args) {
print("Java is easy to learn!");
print("Java is object-oriented!");
print("Java is platform-independent!");
}
public static void print(String s) {
for(int i=0; i<5;i++){
System.out.println(s);
}
}
}