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
Why singleton is not thread safe?
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain
Is null a string?
What is the difference between private & public & friendly classes?
What is the benefit of singleton pattern?
How do you empty a list in java?
List the interfaces which extends collection interface?
Can memory leak happen java?
Can a constructor be made final?
What does the @override annotation do?
What is the output of the below java program?
What are the 4 types of characters?
Can we store variables in local blocks?
What is the default value of byte datatype in java?
Can a class extend more than one class?