首页 > 代码库 > java method 方法的参数与返回值

java method 方法的参数与返回值

public class TestJava4_9 {
public static void main(String args[]) {
int num;
num = star(7);
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;
}
}

java method 方法的参数与返回值