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


Please Help Members By Posting Answers For Below Questions

What does the “static” keyword mean?

581


Is alive and join method in java?

538


Can a class have more than one object?

524


What is an iterator java?

527


Which programming language is best in future?

519






What is a qualifier in a sentence?

520


Can we overload the main() method?

545


What is finalize()? Is finalize() similar to a destructor?

540


What is the difference between final, finally and finalize()?

541


Which is fastest collection in java?

557


Can a class be defined inside an interface?

559


What are internal and external variables?

542


What is final method?

578


Is an array a vector?

550


How do you insert a line break?

492