随笔分类 -  Java

摘要:创建web应用程序 命令模板: mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false如:mvn archetype:generate -DgroupI... 阅读全文
posted @ 2014-02-25 00:06 wouldguan 阅读(204) 评论(0) 推荐(0)
摘要:引用: http://blog.csdn.net/zzqkillyou/article/details/7388690//Javaimport java.util.*;public class Main{ public static int[] shuffle(int[] arr) { int count = arr.length; int[] arr2 = new int[count]; int randCount = 0; //统计已抽取的个数 int position = 0; //随机到的索引 int k = 0; //目标... 阅读全文
posted @ 2013-03-07 12:02 wouldguan 阅读(1313) 评论(0) 推荐(0)
摘要:javapublic class Hello{ public static int binarySearch(int[] a, int key) { int lo=0, hi = a.length-1; while(lo <= hi) { int mid = lo + (hi - lo) / 2; if(key < a[mid]) hi = mid-1; else if(key > a[mid]) lo = mid+1; else return mid; } return -1; } public static vo... 阅读全文
posted @ 2013-02-21 15:07 wouldguan 阅读(129) 评论(0) 推荐(0)
摘要:public class Hello{ private static void quickSort(int data[], int low, int hight) { int i=low,j=hight; int mid=data[(low+hight)/2]; while(i <= j) { while(data[i]<mid) i++; while(data[j]>mid) j--; if(i<=j) { int temp = data[i]; data[i] = data[j]; data[j] = t... 阅读全文
posted @ 2013-02-20 10:28 wouldguan 阅读(2319) 评论(0) 推荐(0)
摘要:package com.temp;import java.util.ArrayList;public class PolymorphismTest{ /** * @param args */ public static void main(String[] args) { ArrayList<Human> persons = new ArrayList<Human>(); persons.add(new Male()); persons.add(new Female()); ... 阅读全文
posted @ 2013-02-10 22:36 wouldguan 阅读(366) 评论(0) 推荐(0)
摘要:来源:http://www.cnblogs.com/whgw/archive/2011/10/05/2199535.htmlJava中单利模式有三种: 懒汉式、饿汉式、登记试饿汉式:public class Singleton { private Singleton() {} private static Singleton instance = new Singleton(); public static Singleton getInstance() { return instance; }}懒汉式:public class Singleton { ... 阅读全文
posted @ 2012-12-18 18:48 wouldguan 阅读(201) 评论(0) 推荐(0)
摘要:原帖在:http://www.coo8ger.com/?p=141服务器端代码:import java.io.*;import java.net.*;public class MyServer { public static void main(String[] args) throws IOException { ServerSocket server = new ServerSocket(5678); Socket client = server.accept(); BufferedReader in = new BufferedReader... 阅读全文
posted @ 2012-12-17 22:37 wouldguan 阅读(167) 评论(0) 推荐(0)