题解 | #输出某一年的各个月份的天数# Calendar
输出某一年的各个月份的天数
https://www.nowcoder.com/practice/6cc6d87805cc4e32866be0541998d8c9
import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner console = new Scanner(System.in); int year = console.nextInt(); //write your code here...... Calendar cal = Calendar.getInstance(); for(int i = 1; i <=12; i++) { cal.set(year,i,0); System.out.println(year + "年"+i+"月:"+cal.getActualMaximum(Calendar.DAY_OF_MONTH)+"天"); } } }
Calendar类
Java语法基础 文章被收录于专栏
基础语法的熟悉