已知两个int变量a、b,定义4个方法分别对变量a、b进行加减乘除运算,并测试结果。
package com.fs.test; public class Test { public void aMethod(int a, int b) { int add = a + b;//*表示加法运算 int reduce = a - b;//*表示减法运算 int multiply = a * b;//*表示乘法运算 int divide = a/b;// a对b整除的数 /表示除法,b不能为0 System.out.println("add = " + add); System.out.println("reduce = " + reduce); System.out.println("multiply = " + multiply); System.out.println("divide = " + divide); } public static void main(String[] args) { Test t = new Test(); t.aMethod(10, 3); } }