- 浏览: 10898 次
- 性别:
- 来自: 上海
最近访客 更多访客>>
文章列表
Creating an Entity
Regular Java classes are easily transformed into entities simply by annotating them. In fact, by adding a couple of annotations, virtually any class with a no-arg constructor can become an entity. Let’s start by creating a regular Java class for an employee.
Listing 2-1 s ...
深入浅出JAVA多线程(1)-方法 JOIN
Posted on 2008-08-23 23:25 advincenting 阅读(10602) 评论(8) 编辑 收藏 所属分类: JAVA基础知识
对于Java开发人员,多线程应该是必须熟练应用的知识点,特别是开发基于Java语言的产品。本文将深入浅出的表述Java多线程的知识点,在后续的系列里将侧重于Java5由Doug Lea教授提供的Concurrent并行包的设计思想以及具体实现与应用。
如何才能深入浅出呢,我的理解是带着问题,而不是泛泛的看。所以该系列基本以解决问题为主,当然我也非常希望读者能够提出更好的解决问 ...
package com.alzhang.chapter03;
import java.util.Comparator;
import java.util.Random;
@SuppressWarnings("unchecked")
public class QuickSort {
public static final Random RND = new Random();
private static void swap(Object[] array, int i, int j) { ...
package org.apache.xmlrpc.demo.webserver;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;
public class JavaServer {
private static fin ...
Singleton: Ensure a class only has one instance and provide a global point of access to it.
code implementation
public class Singleton {
private static Singleton uniqueInstance;
private Singleton() {}
public static Singleton getInstance() {
if (uniqueInstance==null)
uniqueIns ...
let's say you have a pizza shop. you might end up writing some code like this:
Pizza orderPizza() {
Pizza pizza = new Pizza();
pizza.prepare();
pizza.bake();
pizza.cut();
pizza.box();
return pizza;
When you need more than one type of pizza
Pizza orderPizza(String type) {
Pizza pizza;
...
Decorator Pattern: attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
Meet the decorator pattern:
For example, if the customer wants a Dark Roast with Mocha and Whip, then we'll:
1. Take a DarkRoast o ...
Observer pattern: defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
oo principles: strive for loosely coupled designs between objects that interact.
How observer pattern works
let's look at how newspap ...
The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
see SimUDuck app. for reference.
below you'll find a mess of classes and interface for an action adventure game.You'll ...