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 = 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的更多相关文章
- 关于.ToList(): LINQ to Entities does not recognize the method ‘xxx’ method, and this method cannot be translated into a store expression.
LINQ to Entities works by translating LINQ queries to SQL queries, then executing the resulting quer ...
- 『重构--改善既有代码的设计』读书笔记----Replace Method with Method Object
有时候,当你遇到一个大型函数,里面的临时变量和参数多的让你觉得根本无法进行Extract Method.重构中也大力的推荐短小函数的好处,它所带来的解释性,复用性让你收益无穷.但如果你遇到上种情况,你 ...
- org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
前言 本文中提到的解决方案,源码地址在:springboot-thymeleaf,希望可以帮你解决问题. 至于为什么已经写了一篇文章thymeleaf模板引擎调用java类中的方法,又多此一举的单独整 ...
- 重构 改善既有代码的设计 Replace Method with Method Object(以函数对象取代函数)
你有一个大型函数,其中对局部变量的使用使你无法采用Extract Method. 将这个函数放进一个单独对象中,如此一来局部变量就成了对象内的字段.然后你可以在同一个对象中将这个大型函数分解为多个小型 ...
- Python OOP(2)-static method,class method and instance method
静态方法(Static Method): 一种简单函数,符合以下要求: 1.嵌套在类中. 2.没有self参数. 特点: 1.类调用.实例调用,静态方法都不会接受自动的self参数. 2.会记录所有实 ...
- spring init method destroy method
在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...
- 重构改善既有代码设计--重构手法08:Replace Method with Method Object (以函数对象取代函数)
你有一个大型函数,其中对局部变量的使用,使你无法釆用 Extract Method. 将这个函数放进一个单独对象中,如此一来局部变量就成了对象内的值域(field) 然后你可以在同一个对象中将这个大型 ...
- web Form 表单method="get" method="post" 区别
get和post方法的不同 在B/S应用程序中,前台与后台的数据交互,都是通过HTML中Form表单完成的.Form提供了两种数据传输的方式——get和post.虽然它们都是数据的提交方式,但是在实际 ...
- accessor mothod mutator mothod 更改器方法 访问器方法 类的方法可以访问类的任何一个对象的私有域!
LocalDate.plusDate String.toUpperCase GregorianCalendar.add import java.time.*; public class Calenda ...
随机推荐
- Nginx使用手册目录
Nginx学习总结[第一篇]: Nginx简介 Nginx第二篇:Nginx部署及使用 Nginx第三篇:Nginx日志处理 Nginx第四篇:Nginx优化 Nginx第五篇:Nginx日常管理
- 加载 pcntl 多进程
加载 pcntl 有两种方式 一种重新编译安装,在编译时加 --enable-pcntl ./configure --prefix=/usr/local/php --with-mysql=/usr/l ...
- [ios]iOS 图形编程总结
转自:http://www.cocoachina.com/ios/20141104/10124.html iOS实现图形编程可以使用三种API(UIKIT.Core Graphics.OpenGL E ...
- 【转】SVN建库方法
转载地址:http://blog.csdn.net/winonatong/article/details/5791919 SVN全名Subversion,即版本控制系统.SVN与CVS一样,是一个跨平 ...
- poj2395 Out of Hay
题意就是给你一张无向连通图,试问对于图上所有点对(u,v)从u到v的所有路径中边权最大值的最小值的最大值. 定义f(u,v)表示从u到v所有路径中边权最大值的最小值,对所有点对取其最大. 实际上就是求 ...
- poj2269 Friends
计算表达式. 只有3种运算符:*,+,- , *优先级高于后两者,后两者优先级相同. 有两种符号:{},(). 利用递归和堆栈即可解决. 首先遇到左括号开始入栈直到遇到右括号,遇到右括号时对括号内的数 ...
- nn package
1.nn模块是神经网络模块 2.父类module,子类Sequential, Parallel和Concat 3.Linear:做线性变换 4.criterion 这个模块包含了各式各样的训练时的损失 ...
- Python安装指南
说明:我的安装环境是centos6.4 ,32位系统:(#号之后内容为注释说明内容) 1.准备 centos是自带python的,所以可以在shell下直接执行:python 可以看到相应的打印信息, ...
- Bitmap的分析与使用.md
https://github.com/GeniusVJR/LearningNotes/blob/master/Part1/Android/Bitmap的分析与使用.md
- 关于Android6.0之后的权限问题
https://github.com/mylhyl/AndroidAcp AndroidAcp 使用: 加入 compile 'com.mylhyl:acp:1.1.7' PermisionUtils ...