`
文章列表
可以在所截全屏图上连续画任意矩形,有面积标示: import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.event.InputEvent; import java.awt.event.Mou ...
原始程序来源于http://www.iteye.com/topic/149661 是将屏幕所截全图作为Dialog展现,并于其上重绘,以下只到此为止,之后再扩展   import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit ...
所谓双重锁定,就是double-check locking,在instance未被创建时再进行加锁处理,以节省资源 class Singleton { private static Singleton instance; private static final Object syncRoot = new Object(); private Singleton() { } public static Singleton getInstance() { if(instance == null) { synchronized(syncRoot) { ...
Countdown latches are single-use barriers that allow one or more threads to wait for one or more other threads to do something. The sole constructor for CountDownLatch takes an int that is the number of times the countDown method must be invoked on the latch before all waiting threads are allowed ...
The Senior Solution Architect (Systems) has a broad range of technical skills on systems solution. He/she involves leading the architecting and designing of systems solution consisting of Server, Blades, cluster, and management. The Architect has overall responsibility for gathering customer's ...
原型模式实现了shallow clone和deep clone,从而避免大量地新建对象造成资源的严重消耗 现在有这样一个模型:工作经历对简历是合成关系 shallow clone即不复制工作经历 而要实现deep clone,须如此: public Object clone() { Resume obj = new Resume(this.work); obj.name = this.name; obj.sex = this.sex; obj.age = this.age; return obj; }   private Resum ...
工厂方法模式区别于简单工厂的地方是前者克服了后者违背了开闭原则的缺点,即当要新增产品时,不需要修改工厂类,而只需新增一个子工厂即可,将选择判断搬移到了客户端去实现,更大程度实现了OO

代理模式

 图示,代理模式在访问对象时引入一定的间接性来实现许多附加功能。
 策略模式将各种策略即算法封装起来,让变化隔绝于客户端 CashNormal,CashRebate,CashReturn即各种收银算法,第一表示正常收银,第二表示打折优惠,第三表示返利销售,即满多少送多少之类,客户端只要向CashContext传入策略算法类型就能获得对应的CashSuper对象,通过相同的接口(GetResult)获得对应的结果
 上图就是简单计算器UML类图,通过简单工厂模式来创造各种不同的运算类来提供运算能力,通过封装、继承、多态降低程序耦合度来提供较高的可维护性,可复用性和可扩展性。 其中所谓 1.可维护性:要修改哪里就可单独修改哪里,不会牵涉到其它非相关部分,导致一起再编译 2.可复用性:其中的比如运算类(运算逻辑)可完整搬运到其它程序或平台上,而不必修改 3.可扩展性:当要添加新的运算类,比如开平方或MOD时,直接在抽象运算类下扩展,进行实现,不会牵涉到其它许多地方,方便快捷 Let's make it, oo.
先运行一下以下例子: import java.io.BufferedReader; import java.io.CharArrayReader; import java.io.IOException; class BufferedReaderDemo { public static void main(String[] args) throws IOException { String s = "test"; char buf[] = new char[s.length()]; s.getChars(0, s.length(), buf, ...
/** * $Revision: 1.3 $ * $Date: 2009/08/13 03:01:49 $ * * Copyright (C) 2006 Jive Software. All rights reserved. * * This software is published under the terms of the GNU Lesser Public License (LGPL), * a copy of which is included in this distribution. */ package com.ideal.idealim. ...
复制的类在MyEclipse中碰到下面这种状况: 1. class BufferedReaderDemo { 2. public static void main(String[] args) throws IOException { 3. String s = "This is a © copyright symbol but this is & copy not."; 4. char buf[] = new char[s.length()]; 5. s. ...
/** * Create a new session and connect to jabber server host denoted by * <code>route</code> or <code>to</code>. * * @param to * domain of the server to connect to. * @param route * optional hostname of the server to connect to (migh ...
先看这段程序: import java.util.*; class KeyMaster { public int i; public KeyMaster(int i) { this.i = i; } public boolean equals(Object o) { return i == ((KeyMaster) o).i; } public int hashCode() { return i; } } public class Test { public static void main(String[] args ...
Global site tag (gtag.js) - Google Analytics