Tell me the programme for this
@
1 2
@ @ @
1 2 3 4
Answer Posted / thati.donthi
public class PrintTriangle {
public static void main(String[] args) {
int n=4;
for(int i=1;i<=n;i++) {
for(int j=0;j<2*n-i;j++) {
System.out.print(" ");
}
for(int j=1;j<=i;j++) {
if(i%2 != 0) {
System.out.print("@"+" ");
} else {
System.out.print(j+" ");
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
How dead lock situation occurs in java and how you can identify it?
What is treeset in java collection?
Can a method inside a interface be declared as final?
what is the volatile modifier for? : Java thread
What is += mean in java?
Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?
What is the flag in java?
why doesn't java run on all platforms?
How do you replace a string in java?
How do you sing an Applet ?
What exceptions occur during serialization?
How do you clear a method in java?
What is anonymous inner class?
How can we find the sum of two linked lists using stack in java?
What access modifiers can be used for variables?