Program to output as below formate:
1
2 3
4 5 6
7 8 9 10
Answer Posted / dhananjaya nawarathne
public class formatNumbers {
public static void main(String args[])
{
int k=1;
for(int i=1;i<5;i++)
{
for(int j=0;j<i;j++)
{
System.out.print(k++ + " ");
}
System.out.print("
");
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is abstract class? Explain
What is the difference between jdk, jre, and jvm?
What are the four corner stones of oop?
Why volatile is used in java?
Is java call by reference?
Is 0 a prime number?
What is the use of optional ?
Can you give names of Container classes?
What does split function do in java?
Why does java doesnt suuport unsigned values?
Can a class have 2 constructors?
What is singletonlist in java?
What is string example?
How do you escape json?
Can a main method be overloaded?