Time of Update: 2018-12-05
最近學習Lua,在書中看到Lua的table迭代器是用閉包實現的,在java7以前的SDK並不提供閉包功能,java的List的Iterator其實並沒有實現迭代的功能,實際只提供了迭代產生器,調用者需要通過for迴圈或者while迴圈,遍曆 Iterator,筆者參照Lua的閉包Iterat功能,用回調類比了閉包功能,實現了真正的迭代器,調用者不用再遍曆Itertator,即可實現功能,閉包知識參見閉包_維基百科代碼如下:package com.czp;import
Time of Update: 2018-12-05
package com.czp;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.Graphics;import java.awt.Toolkit;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.io.IOException;import java.net.Inet4
Time of Update: 2018-12-05
package com.czp;import java.util.HashMap;import java.util.Stack;public class Calculator {//運算子優先順序private static HashMap<String,Integer> opLs;private String src;public Calculator(String src) {this.src = src;if(opLs==null){opLs = new HashMap<
Time of Update: 2018-12-05
import java.sql.DriverManager; public class TextSS { /* 前期工作還得匯入資料庫驅動包 * * * 1:註冊驅動:三種方式: 1:DriverManager.registerDrive(new com.mysql.jdbc.Driver()); * 2:System.setproperty("jdbc.drivers","com.mysql.jdbc.Driver"); *
Time of Update: 2018-12-05
import java.sql.*;//工具類不是為繼承的,final所以不能繼承,靜態代碼塊只執行一次public final class jdbcUtils {//private static保護起來,能私人就私人,private static String Url="jdbc.mysql://locallhost:3306/jdbc";private static String user="root";private static String passworld="12
Time of Update: 2018-12-05
package wen;import java.sql.*;public class TextSS {/* 前期工作還得匯入資料庫驅動包 * * * 1:註冊驅動:三種方式: 1:DriverManager.registerDrive(new com.mysql.jdbc.Driver()); * 2:System.setproperty("jdbc.drivers","com.mysql.jdbc.Driver"); *
Time of Update: 2018-12-05
1:
Time of Update: 2018-12-05
書籍每個程式員都會有一些由於經常被當作專業資料參閱而磨壞的書。下列書籍應該是 Java 語言程式員的書架上必備的。書很貴,所以我有意將這份列表弄得很短,僅限於重要書籍。Thinking in Java (Bruce Eckel)Thinking in Java, 3rd edition (Bruce Eckel; Prentice Hall PTR,2002 年)Java 編程思想:第3版 (陳昊鵬 等譯; 機械工業出版社,2005 年)Eckel 的書對於學習如何在 Java
Time of Update: 2018-12-05
原文229頁的擷取數組的最大最小值的方法,寫反了public class ArrayUtil { public static class Pair{ private int frist; private int scend; public Pair(int frist, int scend) { super(); this.frist = frist; this.scend = scend; } public int getFrist() { return
Time of Update: 2018-12-05
import java.util.ArrayList;import java.util.List;import java.util.concurrent.Callable;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.Future;/** * * @author CaoZhongping * *非同步任務處理
Time of Update: 2018-12-05
筆者在對map的遍曆方法分別對1000/1萬/10萬條資料的map進行測試時發現方案2比方案1時間上更短:。。。。Map<String,String[]> data = new HashMap<String, String[]>(); for (int i = 0; i < 100000; i++) { data.put("效能(P)"+i, new String[]{"結果查詢","測量管理","閥值管理","自訂指標管理","常用選項",">
Time of Update: 2018-12-05
public static void main(String[] args) throws IOException {String jarPath = "omc-pm-server-eOMC910V100R001C00SPC100B020.jar";String res = readFileFromJar(jarPath,"pm.hbm.xml");System.out.println(res); }/** * 從jar中擷取指定名稱的文字檔 * * @param jarPath *
Time of Update: 2018-12-05
在學習《struts2.0權威指南》的時候遇見了如下錯誤: 配置完成:出現如下錯誤: 嚴重: Exception starting filter struts2 java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.setXmlVersion(Ljava/lang/String;)V我的配置如下: 用了5個jar包: commons-loggin-1.1.jar freemarker-2.3.13.jar
Time of Update: 2018-12-05
package com.czp;public class MathUtil {public static void main(String[] args){double d = 123.5465893;System.out.println(getRealVaule(d, 0));//=>124System.out.println(getRealVaule(d, 3));//=>123.547}/** * 對結果進行四捨五入 * * @param value
Time of Update: 2018-12-05
java ,javaw 和 javaws 的區別:首先,所有的這些都是java的啟動裝置,java.exe經常使用,當使用命令列輸出到window的時候,會有java.exe進程,通過工作管理員可以看到。通常 我們執行一些小的java程式的時候會有
Time of Update: 2018-12-05
package com.czp;/** * * java內部類 * @author CaoZP * */public class OuterClass {/** * * 非靜態內部類 * */public class PublicInnerClass{void test(){System.out.println(getClass());}}/** * 靜態內部類 */public static class StaticInnerClass{void
Time of Update: 2018-12-05
應用: 在做txt閱讀器或者顯示英文字元時,要判斷一個單詞是否被斷開啦。如下簡單代碼能夠自動識別單詞,並且繪畫在螢幕上。 貌似目前很多閱讀器,比如百度文庫和百閱,都沒有對單詞處理。看著相當蛋疼。不過你處理來單詞後,後面將有很多內容 需要處理。這就是百度文庫(android用戶端)或者百閱閱讀器捨棄對文文書處理的原因。package com.docintes.canvas;import android.content.Context;import
Time of Update: 2018-12-05
package com.video.test;public class MyTest {public static void main(String[] args) {String src = "123$456";String desc = reverseString(src);System.out.println(src);System.out.println(desc);//output//123$456//654$321}/** * 倒置字串 * * @param str *
Time of Update: 2018-12-05
// /////////////////////////////////下載檔案功能如下//////////////////////////////////private void DownFile(String urlString){/* * 串連到伺服器 */double FileLength = 0;double DownedFileLength = 0;InputStream inputStream = null;URLConnection connection =
Time of Update: 2018-12-05
基於我們剛剛完成的一個項目的運行檔案來解釋。這個檔案要放在classes目錄下。path %path%java -Xmx256m -Djava.ext.dirs=..\lib com.ait.li.test.SendMessagepause第1行 指定當前路徑為預設路徑第2行 -Xmx256m,為jvm分配256m的記憶體-Djava.ext.dirs=..\lib,指定使用的jar包的目錄com.ait.li.test.SendMessage,main函數所在的類第3行