package Methods;
public class MethodExercise01 {
/**
* @param args
* 1.编写类AAA新方法,判断一个数是奇数ood还是偶数,返回boolean
* 2.根据行、列、字符打印,对应行数和列数的字符,
* 比如:行4列4字符#,则打印相应结果
*/
public static void main(String[] args) {
AAA aaa=new AAA();
aaa.judge(7);
if(!aaa.judge(7)){
System.out.println("偶数");
}else {
System.out.println("奇数");
}
aaa.print(2, 3, 'Z');
}
}
class AAA{
public boolean judge(int n) {
if (n%2==0) {
return false;
} else {
return true;
}
}
public void print(int x,int y, char p){
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
System.out.print(p);
}
System.out.println();
}
}
}
03-28
238
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)