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 unicode used for?
Can we pass null as argument in java?
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
What restrictions are placed on method overloading in java programming?
What is a java predicate?
what are synchronized methods and synchronized statements? : Java thread
What is the flag in java?
What is byte data type?
Is null a value?
What are internal and external variables?
What are the main uses of this keyword?
What are the kinds of polymorphism?
List implementations of list interface?
Can we extend immutable class?
How does arrays sort work in java?