- class Juxing
- {
- public static void main(String[] args)
- {
- method(20,30);
- }
-
- public static void method(int length,int width)
- {
- Rect.widOutter(width);
- for(int i=1;i<length-1;i++)
- Rect.widInner(width);
- Rect.widOutter(width);
- }
-
- }
- class Rect
- {
- public static void widOutter(int width)
- {
- String s=new String(new char[width]);
- System.out.println(s.replace('\u0000','*'));
- }
- public static void widInner(int width)
- {
- String s=new String(new char[width-2]);
- System.out.println("*"+s.replace('\u0000',' ')+"*");
- }
- }
复制代码 |