package step6;

import java.time.DayOfWeek; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters;

/********** Begin *********/ public class TestMonday {

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2022, 4, 1);
    LocalDate firstMonday = date.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY));
    LocalDate lastMonday = date.with(TemporalAdjusters.lastInMonth(DayOfWeek.MONDAY));

    System.out.println("For the month of APRIL all Monday are:");
    while (!firstMonday.isAfter(lastMonday)) {
        System.out.println(firstMonday);
        firstMonday = firstMonday.plusWeeks(1);
    }
}

} /********** End *********

编程要求根据提示在右侧编辑器Begin和End之间补充代码。要求针对给定月份列出该月的所有星期一。测试说明平台会测试数据:测试输入:预期输出:For the month of APRIL all Monday are2022-04-042022-04-112022-04-182022-04-25 package step6; Begin End public class TestMond

原文地址: https://www.cveoy.top/t/topic/dxGa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录