New to Java loops need a little help
So I am new to Java and need some help and possible explanation. I have created code that prints out the desired pattern, but I am not sure how to make each set of stars on its own line. Here's my code I have so far.
Code:
public class Loop1 {
public static void main(String[] args) {
// TODO code application logic here
for(int r = 0; r <= 5; r++){
for (int c = 0; c < r+1; c++){
System.out.print(" ");
}
for(int j = 0; j < r; j++){
System.out.print("*");
}
}
}
}
Here's my output:
Code:
* ** *** **** *****
Once I am done I will want it to be a diamond pattern, but I will get to that part in the next few days/weeks. I am just trying to get a firm understanding of how the code works.