I am very new in the programming world and in Javaland too. I am trying to learn for loop and solving pattern with it.
I want to draw this pattern using for loop :
*
**
***
****
*****
I am using this code to achieve this:
public class PatterWithForLoop {
public static void main(String args[]){
for(int i = 0; i <= 5; i++){
System.out.println("*" + "\n");
}
}
}
But, I am only getting * in 15 lines, not in the pattern. Please, anyone can help to solve this issue here?
Thanks in advance.
forloop shouldn't run any iteration at all.printandprintln.