首页 > 代码库 > accessor method & mutator method
accessor method & mutator method
import java.time.*; public class MyTest{ public static void main(String[] args){ LocalDate date = LocalDate.now(); int month = date.getMonthValue(); int today = date.getDayOfMonth(); date = date.minusDays(today - 1); DayOfWeek weekday = date.getDayOfWeek(); int value =http://www.mamicode.com/ weekday.getValue(); System.out.println("Mon Tue Wed Thu Fri Sat Sun"); for(int i = 1; i < value; i ++) System.out.print(" "); while(date.getMonthValue() == month){ System.out.printf("%3d", date.getDayOfMonth()); if(date.getDayOfMonth() == today) System.out.print("*"); else System.out.print(" "); date = date.plusDays(1); if(date.getDayOfWeek().getValue() == 1) System.out.println(); } if(date.getDayOfWeek().getValue() != 1) System.out.println(); } }
date = date.minusDays(today - 1); 更改了 date 所引用的对象
accessor method & mutator method
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。