方法设计技巧:
package com.itheima.Method; public class Method3 { public static void main(String[] args) { System.out.println(sum(10)); pan(5); } public static int sum(int n){ int sum=0; for (int i = 1; i <= n; i++) { sum +=i; } return sum; } public static void pan(int a){ String b=a % 2 == 0 ? "偶数" : "奇数"; System.out.println(b); } }
标签:JAVA,int,sum,案例,static,方法,public From: https://www.cnblogs.com/pengsuoqun123/p/18045388