提供相對安全和相對粗暴的兩種介面勝過單一的介面類java.util.concurrent.ThreadPoolExecutor方法shutdown在終止前允許執行以前提交的任務。code/** * Initiates an orderly shutdown in which previously submitted * tasks are executed, but no new tasks will be accepted. * Invocation has no additional
設計模式-04-單例模式本文參考自《Java與模式》以及http://baike.baidu.com/view/1859857.htm一、單例類的特點1.某個類只能有一個執行個體。2.構造器是private的(因此,單例類不能被繼承)。3.單例類必須自行建立自己的唯一執行個體。二、單例的分類1.餓汗式單例類a.類圖b.Codepackage com.jue.dp;public class EagerSingleton {private static final EagerSingleton
本文參考了《編寫可讀代碼的藝術》,寫的好!參考連結:http://www.cnblogs.com/pengyingh/articles/2445826.html一、特殊的注釋FIXME 來源:android/packages/apps/Mms/src/com/android/mms/ui/SlideView.java表意:代碼不能正常工作,急需修複的private Uri getSelectedUriFromMessageList(ListView listView, int position)
本文參考自《設計模式之禪》,《Java與模式》一、通過給出一個原型對象來指明所要建立的對象的類型。二、Java中半支援1.Ojbect類提供一個clone方法。2.Java必須實現Cloneable來顯式表明Javabean支援複製。3.如果不實現Cloneable介面而直接使用,會拋出java.lang.CloneNotSupportedException。4.預設的實現是淺拷貝,需要重寫clone方法。三、Codepackage com.jue.dp;public class TV
Hi,I had just found the steps as following.1.create a sequence diagram like the following.2.add a CombinedFragment1 into diagram like the following.3.change the "seq CombinedFragment1 " to "alt CombinedFragment1 "4.select the "Interaction
1.可以在指定的時間得到回調。2.可以取消上一次特定時間的請求。3.在上一次的請求回複之前,可以設定新的請求,並且上次的請求會自動無效。/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the
題目:從一個數組中找到和最大的子數組,數組中可能有負數。想法:窮舉法實現次問題,列出所有情況,進行比較記錄!編寫一個計算數組中某個範圍內的和的方法。依次遍曆所有的情況,記錄最大值。C++實現如下://============================================================================// Name : MaxSubArray.cpp// Author : jue// Version ://
JSONObject提供了擷取String的一個方法,當查詢失敗的時候,會拋出異常。public String getString(String key) {verifyIsNull();Object o = get(key);if (o != null) {return o.toString();}throw new JSONException("JSONObject[" + JSONUtils.quote(key)+ "] not
問題:如何判斷兩個鏈表相交於某結點?分析:圖紙描述鏈表相交時候情境!發現相交與不相交的區別與特點!結論:發現相交的鏈表,相交點後面的結點都是相同的,通過簡化,可以得出最後一個結點必是同一個結點。//============================================================================// Name : LinedListCrossing.cpp// Author : jue// Version :/
本文參考自《編寫可讀代碼的藝術》,這本書寫的非常好!對於一個布林運算式,有兩種寫法:! (a or b or c) = ( !a ) and ( !b ) and ( !c )! ( a and b and c) = ( !a ) or ( !b ) or (!c)延伸到編程,右面的運算式會感覺更容易懂些。一個例子if (!(fileExist && !isProcted)) {System.out.println("Sorry, could not read the