Tell me the programme for this
@
1 2
@ @ @
1 2 3 4
Answer Posted / chantiraji
public class TriangleDisplay {
public static void main(String[] args) {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 4; 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 ? | 0 Yes | 0 No |
Post New Answer View All Answers
Suppose if we have variable ' I ' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?
What is the difference between multiple processes and multiple threads?
What is the statements?
Explain what is Marker interface?
What is a hashmap used for?
Can I learn java without any programming experience?
What is busy spin, and why should you use it?
How will you invoke any external process in java?
Can a set contain duplicates?
Is empty in java?
What are abstract classes and anonymous classes?
What is the difference between an interface and an abstract class?
What are different ways of object creation in java ?
Can inner class have constructor?
how to prepare for IT Officers Interview in Banks