思路:
使用Calendar类计算
代码实现:
import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int y=in.nextInt(); int m=in.nextInt(); int d=in.nextInt(); Calendar c1=Calendar.getInstance();//实例化 c1.set(y, m-1, d);//注意月份从0开始 System.out.println(c1.get(Calendar.DAY_OF_YEAR)); } }