Gadgets

Showing posts with label print square. Show all posts
Showing posts with label print square. Show all posts

Wednesday, 9 December 2015

Print Square in java

Print Square in java
public class PrintSquare {
    public static void main(String[] arg){
                               //print first line
        for(int i=1;i<=15;i++){
            System.out.print("*");
        }                    
        System.out.println("");//print new line
                               //print first *
        for(int j=1;j<=5;j++){
            System.out.print("*");
                                              //print spaces
            for(int space=1;space<=13;space++){
                System.out.print(" ");
            }                                
            System.out.print("*");//print end *
            System.out.println("");//print new line
        }
         for(int i=1;i<=15;i++){
            System.out.print("*");//print end line
        }       
    }   
}
/*
Output:
***************
*                   *
*                   *
*                   *
*                   *
*                   *
***************

*/