I'm doings some beginners task in JAVA. With the help of FOR I'm going to create two simple triangles by just adding simple characters like * to a string like this:
*
**
***
****
*****
and
*****
****
***
**
*
I have done the first triangle with the code below, perhaps it could be done in some simplier/smarter way? But I'm not sure how to create the other triangle that starts with five * ?
public class Test {
public static void main(String[] args) {
String word = "";
for (int x=1; x<5+1; x++){
word += "*";
System.out.println(word);
}
}
}