上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: 测试注解类 解析注解: 运行结果: 阅读全文
posted @ 2016-09-25 20:24 cutter_point 阅读(173) 评论(0) 推荐(0)
摘要: 分别使用序数和enummap的结果: 序数: test1() 使用enummap,tes1t 阅读全文
posted @ 2016-09-25 18:03 cutter_point 阅读(628) 评论(0) 推荐(0)
摘要: 有的时候我们一个容器只有一个类型或几个类型并不能满足我们的要求,比如set中存放的元素类型都是同一种,map也就指定的两种 这里我们可以将键进行参数化,而不是将容器参数化,也就是我们可以给容器传一个键的类型,然后value用来放对应的实例,这样就可以存放多个不同的类型了 如: 运行显示结果: 异构成 阅读全文
posted @ 2016-09-20 22:33 cutter_point 阅读(567) 评论(0) 推荐(0)
摘要: 但是有的时候,我们发现使用泛型的时候,在调用构造器的时候要明确泛型的类型,这样书写很麻烦 这里可以使用一个泛型静态方法,利用泛型的类型推导 关于泛型单利工厂的实现 显示结果: 阅读全文
posted @ 2016-09-18 22:19 cutter_point 阅读(440) 评论(0) 推荐(0)
摘要: 这个,不管是什么书都会这样说,因为常常我们并不需要继承,而只是想把类进行一定的扩展,而我们想扩展的属性或方法对应的类都有,这个时候如果两者是is a的关系,这种关系是确实存在的,那么就可以使用继承,不然一般都是建议使用复合。 如果我们队一个类进行继承的时候,我们如果对其内部的逻辑并不十分了解的时候, 阅读全文
posted @ 2016-09-12 22:12 cutter_point 阅读(555) 评论(1) 推荐(0)
摘要: package cn.xf.cp.ch02.item9; import java.util.HashMap; import java.util.Map; public class PhoneNumber { private final short areaCode; private final short prefix; private final short lin... 阅读全文
posted @ 2016-09-08 22:19 cutter_point 阅读(450) 评论(5) 推荐(0)
摘要: 首先写一个点类 然后是一个颜色的,枚举 开始重写其equals方法,来综合比较颜色和点的属性 在实现这样的比较的时候 使用复合优先于继承 我们使用复合的方式来做就会方便很多 阅读全文
posted @ 2016-09-08 22:03 cutter_point 阅读(202) 评论(0) 推荐(0)
摘要: 创建对象的时候,有些变量可以一直保持的时候,可以不必要每次实例化对象的时候都把这些变量初始化一遍,可以使用静态和静态块的方式把这些变量的数据固定下来 把上面的代码改进到使用静态代码块的模式 这样的话每次创建对象的时候,调用方法使用的私有变量都是最开始初始化好了的,如果调用这个方法的用户特别多,上千万 阅读全文
posted @ 2016-09-05 22:00 cutter_point 阅读(240) 评论(0) 推荐(0)
摘要: package cn.xf.cp.ch02.item2; /** * * 功能:当我们的构造参数有很多,超出可控范围的时候,用build模式 时间:下午8:25:05 文件:NutritionFacts.java * * @author Administrator * */ public class NutritionFacts { private final int ... 阅读全文
posted @ 2016-09-04 20:39 cutter_point 阅读(242) 评论(0) 推荐(0)
摘要: 使用一个服提供者对进行服务的提供,服务的请求通过不同的提供者提供不同的服务,服务提供者首先必须在工厂中进行注册,然后才可以通过工厂实例化服务 Service.java ServicesFactory.java 测试代码 结果显示: 阅读全文
posted @ 2016-09-04 19:37 cutter_point 阅读(264) 评论(0) 推荐(0)
摘要: 关于MethodHandle类,这个类是在jdk1.7之后加入的,这个类的作用类似函数指针的意思 这个类中有一个方法 这里我的jdk有一个问题,就是我在进行MethodHandle操作的时候,我们会发现我们的方法只能设定想要的返回值和参数,但是我们相应的方法里面却不能对这些方法进行操作,参数能操作的 阅读全文
posted @ 2016-04-15 11:10 cutter_point 阅读(614) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.TemplateMethod; 2 3 4 /** 5 * 功能:抽象模板类 6 * 时间:2016年3月10日下午9:02:32 7 * 作者:cutter_point 8 */ 9 public abstract class 阅读全文
posted @ 2016-03-10 21:12 cutter_point 阅读(315) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Strategy; 2 3 4 /** 5 * 功能:上班的接口 6 * 时间:2016年3月9日下午8:53:34 7 * 作者:cutter_point 8 */ 9 public interface ToWork 10 { 阅读全文
posted @ 2016-03-09 21:54 cutter_point 阅读(419) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.State; 2 3 4 /** 5 * 功能:状态接口 6 * 时间:2016年3月8日下午9:41:17 7 * 作者:cutter_point 8 */ 9 public interface State 10 { 11 / 阅读全文
posted @ 2016-03-08 22:21 cutter_point 阅读(411) 评论(3) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Observer; 2 3 4 /** 5 * 功能:学生观察者 6 * 时间:2016年3月7日上午10:28:00 7 * 作者:cutter_point 8 */ 9 public interface Student 10 阅读全文
posted @ 2016-03-07 11:01 cutter_point 阅读(548) 评论(2) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Memento; 2 3 4 /** 5 * 功能:游戏角色 6 * 时间:2016年3月6日下午9:39:18 7 * 作者:cutter_point 8 */ 9 public class GameRole 10 { 11 阅读全文
posted @ 2016-03-06 22:23 cutter_point 阅读(484) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Mediator; 2 3 4 /** 5 * 功能:领导者接口 6 * 时间:2016年3月5日下午10:41:35 7 * 作者:cutter_point 8 */ 9 public interface Leader 10 阅读全文
posted @ 2016-03-05 23:30 cutter_point 阅读(315) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Iterator; 2 3 4 /** 5 * 功能:我们的迭代器接口 6 * 时间:2016年3月4日上午9:17:36 7 * 作者:cutter_point 8 */ 9 public interface MyIterat 阅读全文
posted @ 2016-03-04 09:35 cutter_point 阅读(275) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Interpreter; 2 3 4 /** 5 * 功能:演奏文本 6 * 时间:2016年3月3日上午9:26:19 7 * 作者:cutter_point 8 */ 9 public class PlayContext 1 阅读全文
posted @ 2016-03-03 10:06 cutter_point 阅读(216) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.Command; 2 3 4 /** 5 * 功能:接收命令着者,这个人可以执行多种命令 6 * 时间:2016年3月2日上午11:07:30 7 * 作者:cutter_point 8 */ 9 public class Re 阅读全文
posted @ 2016-03-02 14:00 cutter_point 阅读(521) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.behavioral.ChainOfResponsibility; 2 3 4 /** 5 * 功能:问题类型 6 * 时间:2016年3月1日上午9:59:18 7 * 作者:cutter_point 8 */ 9 public enum Ques 阅读全文
posted @ 2016-03-01 10:26 cutter_point 阅读(358) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.structural.Proxy; 2 3 4 /** 5 * 功能:为其他对象提供一种代理以控制这个对象的访问 6 * 适用:1、远程代理,为一个对象在不同的地址空间提供局部代表 7 * 2、虚代理,根据需要创建开销很大的对象 8 * 3、保护代理 阅读全文
posted @ 2016-02-29 10:34 cutter_point 阅读(323) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.structural.Flyweight; 2 3 4 /** 5 * 功能:运用共享技术有效地支持大量细粒度的对象,这个就是作为享元的类 6 * 适用:1、一个应用程序使用了大量的对象 7 * 2、完全由于使用大量的对象、造成很大的存储开销 8 * 阅读全文
posted @ 2016-02-27 22:49 cutter_point 阅读(291) 评论(0) 推荐(0)
摘要: 外观模式就是把一堆子类,用一个外观类进行封装,然后把他们的功能总结起来,然后用外观类实现,用这封装使用频繁的方法 1 package com.shejimoshi.structural.Facade; 2 3 4 /** 5 * 功能:显示器类,作为子系统 6 * 时间:2016年2月26日下午12 阅读全文
posted @ 2016-02-26 12:28 cutter_point 阅读(267) 评论(0) 推荐(0)
摘要: 1 package com.shejimoshi.structural.Decorator; 2 3 4 /** 5 * 功能:这个是我们装饰器的基类,用来生成被装饰类和装饰器类 6 * 时间:2016年2月25日上午10:05:37 7 * 作者:cutter_point 8 */ 9 publi 阅读全文
posted @ 2016-02-25 11:33 cutter_point 阅读(265) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 下一页