摘要: public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); int count = 0; for(int i = 0;i < 32;i+ 阅读全文
posted @ 2021-01-06 18:58 LinYanyan 阅读(73) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { int a = 9; int b = 18; int c = 0; while (a % b != 0) { c = a %b; a = b; b = c; } System.out.println(c); } 阅读全文
posted @ 2021-01-06 18:56 LinYanyan 阅读(377) 评论(0) 推荐(0) 编辑
摘要: public class Main { public static double func(int i,int j) { double ret = 1.0/i - 1.0/j; return ret; } public static void main(String[] args) { double 阅读全文
posted @ 2021-01-06 18:48 LinYanyan 阅读(221) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 1; i ⇐ n ; i++) { int count 阅读全文
posted @ 2021-01-06 18:22 LinYanyan 阅读(177) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Random random = new Random(); int ranNum = random.nextInt(100) + 1; 阅读全文
posted @ 2021-01-06 18:18 LinYanyan 阅读(142) 评论(0) 推荐(0) 编辑
摘要: public static void printX(int m) { for (int x = 1; x ⇐ m; x++) { for (int y = 1; y ⇐ m; y++) { if (x == y || x + y == m + 1) { System.out.print("*"); 阅读全文
posted @ 2021-01-06 18:16 LinYanyan 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 根据输入的年龄, 来打印出当前年龄的人是少年(低于18), 青年(19-28), 中年(29-55), 老年(56以上)(这道题好像有瑕疵,没得满分,有缘人帮忙看看) public static void main(String[] args) { while(true){ System.out.p 阅读全文
posted @ 2021-01-06 18:12 LinYanyan 阅读(356) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); for (int j = 0; j ⇐ num; j++) { int i 阅读全文
posted @ 2021-01-06 18:09 LinYanyan 阅读(132) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { int count = 0; for (int i = 2; i < 101; i++) { for (int j = 2; j ⇐ i; j++) { if (i % j == 0 && i != j) break; 阅读全文
posted @ 2021-01-06 18:07 LinYanyan 阅读(842) 评论(0) 推荐(0) 编辑
摘要: 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。Template Method使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤。 Template Method模式一般是需要继承的。这里想要探讨另一种对Template Method的理解。Spring中的JdbcTemplate 阅读全文
posted @ 2021-01-06 18:06 LinYanyan 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。本模式使得算法可独立于使用它的客户而变化。 Spring中在实例化对象的时候用到Strategy模式,见如下图: 在SimpleInstantiationStrategy中有如下代码说明了策略模式的使用情况: 阅读全文
posted @ 2021-01-06 18:05 LinYanyan 阅读(658) 评论(0) 推荐(0) 编辑
摘要: 定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新。 Spring中Observer模式常用的地方是listener的实现。如ApplicationListener。 阅读全文
posted @ 2021-01-06 18:03 LinYanyan 阅读(1062) 评论(0) 推荐(0) 编辑
摘要: 为其他对象提供一种代理以控制对这个对象的访问。 从结构上来看和Decorator模式类似,但Proxy是控制,更像是一种对功能的限制,而Decorator是增加职责。 Spring的Proxy模式在aop中有体现,比如JdkDynamicAopProxy和Cglib2AopProxy。 阅读全文
posted @ 2021-01-06 18:02 LinYanyan 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 动态地给一个对象添加一些额外的职责。就增加功能来说,Decorator模式相比生成子类更为灵活。 Spring中用到的包装器模式在类名上有两种表现:一种是类名中含有Wrapper,另一种是类名中含有Decorator。基本上都是动态地给一个对象添加一些额外的职责。 阅读全文
posted @ 2021-01-06 18:01 LinYanyan 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 Spring中在对于AOP的处理中有Adapter模式的例子,见如下图: 由于Advisor链需要的是MethodInterceptor(拦截器)对象,所以每一个Advisor中 阅读全文
posted @ 2021-01-06 18:00 LinYanyan 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 保证一个类仅有一个实例,并提供一个访问它的全局访问点。 Spring中的单例模式完成了后半句话,即提供了全局的访问点BeanFactory。但没有从构造器级别去控制单例,这是因为Spring管理的是是任意的Java对象。 阅读全文
posted @ 2021-01-06 17:58 LinYanyan 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 定义一个用于创建对象的接口,让子类决定实例化哪一个类。Factory Method使一个类的实例化延迟到其子类。 Spring中的FactoryBean就是典型的工厂方法模式。如下图: 阅读全文
posted @ 2021-01-06 17:56 LinYanyan 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 又叫做静态工厂方法(StaticFactory Method)模式,但不属于23种GOF设计模式之一。 简单工厂模式的实质是由一个工厂类根据传入的参数,动态决定应该创建哪一个产品类。 Spring中的BeanFactory就是简单工厂模式的体现,根据传入一个唯一的标识来获得Bean对象,但是否是在传 阅读全文
posted @ 2021-01-06 17:55 LinYanyan 阅读(147) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { for(int year = 1000;year ⇐ 2000;year++){ if((year % 4 == 0 && year % 100 != 0) || year % 400 ==0){ System.out 阅读全文
posted @ 2021-01-06 17:53 LinYanyan 阅读(758) 评论(0) 推荐(0) 编辑
摘要: 1、https协议需要到ca申请**,一般免费**较少,因而需要一定费用。 2、http是超文本传输协议,信息是明文传输,https则是具有安全性的ssl加密传输协议。 3、http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443。 4、http的连接很简单,是无状 阅读全文
posted @ 2021-01-06 17:52 LinYanyan 阅读(2435) 评论(0) 推荐(0) 编辑