It's a long time from my last Java program, for I usually work using C/C++/Objective-C. In this week, I decide to deal with my data from experiment. There are so many data files and it is a depressing work to turn them into a usable format. So I
class ArrayBub { private long[] a; // ref to array a private int nElems; // number of date items public ArrayBub(int max) { // constructor a = new long[max]; // create the array nElems = 0; // no items yet } /**
1,冒泡法: public class BubbleSortImpl1 {public static void BubbleSort(int A[]) { int n = A.length; for(int i=0;i<n;i++){ for(int j=0;j<n-i-1;j++){ if(A[j]>A[j+1]) { int temp=A[j]; A[j]=A[j+1];
文章目錄 Calling JavaOptimizing for PerformanceException Handling Working with JavaIn this chapter, you will see how Clojure access to Java is convenient, elegant, and fast: • Calling Java is simple and direct.
因為寫了些bean作為quartz的任務用spring配置了,但有些時候需要在別的類中使用這些bean,沒有太仔細去研究spring,依稀記得有個getBean,到網上g了一把,探索方法不止一種,選了一種最簡單的方法: 主要思路是使用靜態變數儲存全域的應用上下文,在spring架構中配置,架構載入時會把全域上下文執行個體傳入。 1、建立繼承ApplicationContextAware的類:Code highlighting produced by Actipro
SocketChannel vs. ServerSocketChannel父類:SelectableChannel。Channel表現了一個可以進行IO操作的通道(比如,通過FileChannel,我們可以對檔案進行讀寫操作)ServerSocketChannel主要用在Server中,用於接收用戶端的連結請求 SocketChannel則用於真正的讀寫資料,同時還可以用於用戶端發送連結請求。
Factory大概是最簡單的設計模式了,用了一些,也該理一理了。我們先看看它的模式模式圖: 簡單的說,原廠模式就是把“產品”與“產品生產”分離,然後對“產品”進行抽象。這樣就形成了一個簡單原廠模式。如果你再對“產品生產”這個環節進行抽象,那麼就得到方法原廠模式。如果你在方法原廠模式裡有多個產品足,那麼就形成了抽象工廠。 那就分別對以上三種舉例吧: 1.簡單工廠 1 //client 2 public class