Search Java Programs

Wednesday, January 20, 2010

Simple java program

public class Print{
public static void main(String[] args){
int i=1;
int j;
while(i<=7){
for(j=1;j<=i;j++)
System.out.print("*");
i=i+2;
System.out.println();
}
i=5;
while(i>=1){
for(j=1;j<=i;j++)
System.out.print("*");
i=i-2;
System.out.println();
}
}
}

Answer

Out put of Print.java

*
***
*****
*******
*****
***
*

No comments:

Post a Comment

Website Design by Mayuri Multimedia