public class TestJava4_9 {
public static void main(String args[]) {
int num;
num = star(7); //运行star(7)方法,然后把返回值赋给num
System.out.println(num+" stars printed");
}
public static int star(int n) {
for (int i = 1; i < 2*n; i++) {
System.out.print("*");
}
System.out.print("\n");
return 2*n; //star()的返回值是:2*n
}
}
public static void main(String args[]) {
int num;
num = star(7); //运行star(7)方法,然后把返回值赋给num
System.out.println(num+" stars printed");
}
public static int star(int n) {
for (int i = 1; i < 2*n; i++) {
System.out.print("*");
}
System.out.print("\n");
return 2*n; //star()的返回值是:2*n
}
}