public static void main(String[] args) { //int sum= add(1,2); // System.out.println(sum); test(); } public static int add (int a, int b){ return a+b; } public static void test(){ //输出1到1000中能被5整除的数 每行三个 for (int i = 0; i <= 1000; i++) { if (i % 5 == 0) { System.out.print(i + "t"); if (i % 3 == 0) { System.out.println(); // System.out.print("n"); } } } }方法的定义和调用
public static void main(String[] args) { int a = 3; int b = 3; int m = max(a, b); System.out.println(m); } //比大小 public static int max(int num1, int num2) { int result = 0; if (num1 == num2) { return 0; } if (num1 > num2) { result = num1; } else { result = num2; } return result; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)