public class HelloWorld{ public static void main(String[] args) { int one = 10 ; int two = 20 ; int three; three = one+two; System.out.println("three"+"="+three); three += one; System.out.println("three"+"="+three); three -=one; System.out.println("three"+"="+three); three *= one; System.out.println("three"+"="+three); three /=one; System.out.println("three"+"="+three); three %= one; System.out.println("three"+"="+three ); }}
1 回答
已采纳
小羊羊ly
TA贡献2条经验 获得超0个赞
定义一个静态方法output,参数类型为int,方法体中是输出语句,输出语句参数即output方法的参数。这样就只用写一次System.out.print方法,需要输出时调用output()方法即可
添加回答
举报
0/150
提交
取消