Program to output as below formate:
1
2 3
4 5 6
7 8 9 10

Answer Posted / jyoti

public class format {
public static void main(String args[])
{
int k=1;
for(int i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
System.out.print(k++ + " ");
}
System.out.print("\n");
}
}
}

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can final class have constructor?

490


List the different types of classloaders in java.

496


What is object english?

570


Is nullpointerexception checked or unchecked?

549


What is java abstraction with example?

545






Difference between static synchronization vs. Instance synchronization?

552


What are the advantages of java?

501


How do you add an element to an arraylist in java?

476


What’s meant by anonymous class?

588


What is diamond operator in java?

489


What is a package in java? List down various advantages of packages.

744


What is the difference between break and continue statements?

541


Does list allow duplicates in java?

512


What are access specifiers in java ?

586


when you will synchronize a piece of your code? : Java thread

523