1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package 控制语句;
public class TestMethod { public static void main(String[] args) { TestMethod obj = new TestMethod(); obj.Method_1(); obj.Method_2(1, 2); int total = obj.Method_3(1, 2); System.out.println(total); } void Method_1() { System.out.println("This is Method_1"); } void Method_2(int a,int b) { int sum = a+b; System.out.println(sum); } int Method_3(int a,int b) { int sum = a+b; return sum; } }
|