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
How hashset works internally in java?
What is local variable and instance variable?
What is the main function in java?
What is the difference between heap and stack memory?
Explain about fail fast iterators in java?
Can we inherit a class with private constructor?
Tell me the Importent classes in net package?
How do you clear an arraylist in java?
What are different types of arrays?
Which methods are used during serialization and deserialization process?
Can we use different return types for methods when overridden?
What are encapsulation, inheritance and polymorphism?
Is boolean a wrapper class in java?
What is definition and declaration?
What are selection structures?