int a=0; while(a<10){ int b=0; if(a ==0 || a==9){ while(b<20){ b++; System.out.print("B"); } }else{ System.out.println("B B"); } a++; }