I need to right justify the next output using Java:
class MyTree {
public static void staircase(int n) {
String myGraph = "#";
for(int i=0; i<n; i++){
for(int x = 0; x <=i; x++){
if(x == i){
System.out.printf("%s\n", myGraph);
}else{
System.out.printf("%s", myGraph);
}
}
}
}
}
I'm using printf function but I'm stuck, I tried different parameters but nothing seems to work; in case you have a suggestion please let me know.
Thanks