代码块eg:
package xiafly;
import java.util.Scanner;
//import com.xiafly.*; //import导入,可以导入其他包下的类
public class Metood {
public static void love(int num) { //形参
// Scanner s = new Scanner(System.in);
//
// System.out.printf("请输入年数:");
// num = s.nextInt();
System.out.printf("我爱你" + "" + num + "年");
}
public static int add(int a, int b, int c) {
int sum = a + b + c;
System.out.printf("\n" + sum);
return sum;
}
public static void main(String[] args) {
love(2); //实参
int a = 1 + add(1, 2, 3);
System.out.printf("\n" + a);
}
}
运行结果:
我爱你2年
6
7
Process finished with exit code 0