How to print the given format in java
*
* *
* * *
* * * *
* * * * *
Code for given format..
public class Test
{
public static void main(String args[])
{
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
The first for loop is used to change the line
the second loop is used to print the *
*
* *
* * *
* * * *
* * * * *
Code for given format..
public class Test
{
public static void main(String args[])
{
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
The first for loop is used to change the line
the second loop is used to print the *
No comments:
Post a Comment