Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java×Ö·û´®´¦ÀíÀà

×Ô¼ºÊÕ¼¯µÄһЩjava´¦ÀíÀ࣬¹©ÒÔºó²éѯ
package com.tools;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StringHandler {

/******************************
* ¹¦ÄÜ£º½«IPµØַת»»Îª¶ÔÓ¦µÄÕûÊý
* ·µ»ØÀàÐÍ£ºlong
******************************/
public static long getIpNum(String ip){
long ipNum=0;
if(ip!=null && !ip.equals("")){
String[] subIp=ip.split("\\.");
for(int i=0;i<subIp.length;i++){
ipNum=ipNum<<8;
ipNum+=Integer.parseInt(subIp[i]);
}
}
return ipNum;
}

/******************************
* ¹¦ÄÜ£º¸ñʽ»¯Ê±¼äΪÄê-ÔÂ-ÈÕ Ê±-·Ö-Ãë
* ·µ»ØÀàÐÍ£ºString
******************************/
public static String timeTostr(Date date){
String strDate="";
if(date!=null){
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
strDate=format.format(date);
}
return strDate;
}

/**********************************
*·½·¨Ãû: chStr()
*¹¦ ÄÜ:½â¾öÊä³öÖÐÎÄÂÒÂëÎÊÌâ
*·µ»ØÀàÐÍ£ºString
***********************************/
public String chStr(String str){
if(str==null){ //µ±±äÁ¿strΪnullʱ
str=""; //½«±äÁ¿str¸³ÖµÎª¿Õ
}else{
try{
str=(new String(str.getBytes("iso-8859-1"),"GB2312")).trim();//½«×Ö·û´®×ª»»ÎªGBK±àÂë
}catch(Exception e){
e.printStackTrace(System.err); //Êä³öÒì³£ÐÅÏ¢
}
}
return str; //·µ»Øת»»ºóµÄÊäÈë±äÁ¿str
}
/***************************************************
*·½·¨Ãû:convertStr()
*¹¦ ÄÜ:ÏÔʾÎı¾ÖеĻسµ»»ÐС¢¿Õ¸ñ¼°±£Ö¤HTML±ê¼ÇµÄÕý³£Êä³ö
*·µ»ØÀàÐÍ: String
**************************************************/
public String convertStr(String str1){
if(str1==null){
str1="";
}else{
try{
//replaceAll(String str1,String str2)·½·¨ÎªJDK1.4.xµÄз½·¨£¬Ê¹ÓÃstr2Ìæ»»×Ö·û´®ÖеÄËùÓÐstr2×Ö·û´®
str1=str1.replaceAll("<","<");//Ìæ»»×Ö·û´®ÖеÄ"<"ºÍ">"×Ö·û£¬±£Ö¤HTML±ê¼ÇµÄÕý³£Êä³ö
str1=str1.replaceAll(">",">


Ïà¹ØÎĵµ£º

ѧϰJavaÀàµÄÊôÐÔ

ѧϰJavaÀàµÄÊôÐÔ-Î人±±´óÇàÄñ
¡¡¡¡Public¡¢private¡¢protectedÏÔʾÁËÈýÖÖÀàÖеÄÊôÐԺͷþÎñµÄÀàÐÍ£¬publicÊÇ¿ÉÒÔËæÒâ·ÃÎʵġ¢privateÊÇÍâ½ç²»ÄÜ·ÃÎʵÄ(ÏÔʾÁËÊý¾ÝµÄ·â×°ÐÔ)¡¢protected˵Ã÷Êý¾ÝÊÇÊܱ£»¤µÄ¡£ÏÂÃæ¾ÍÀ´Ïêϸ½²ÊöÒ»ÏÂÕâÈý¸ö¾¿¾¹ÓÐʲôÇø±ð¡£
¡¡¡¡Ê×ÏÈÒªÁ˽âһϰüµÄ¸ÅÄî¡£ÓÐÈô¸É¸öÀ࣬ËüÃÇÏ໥֮¼äÓÐÒ»¶¨µÄ¹ØÏ ......

JavaÉè¼Æģʽ֮State(״̬ģʽ)

¶¨Ò壺
GOF¡¶Éè¼Æģʽ¡·Öиø״̬ģʽϵĶ¨ÒåΪ£ºÔÊÐíÒ»¸ö¶ÔÏóÔÚÆäÄÚ²¿×´Ì¬¸Ä±äʱ¸Ä±äËüµÄÐÐΪ¡£
ÏÈ¿´Ò»¸öÀý×Ó£º
package com.state;
public class KissingPrincess {
// ±ê־룬±êÖ¾ÊÇÇàÍÜ»¹ÊÇÍõ×Ó¡£
private boolean isFrog = true;
// ¸ù¾ÝisFrog½øÐв»Í¬µÄ²Ù×÷¡£
public void greet() {
if (isFrog)
......

Java Reflection (JAVA·´Éä)

Reflection ÊÇ Java ³ÌÐò¿ª·¢ÓïÑÔµÄÌØÕ÷Ö®Ò»£¬ËüÔÊÐíÔËÐÐÖÐµÄ Java ³ÌÐò¶Ô×ÔÉí½øÐмì²é£¬»òÕß˵“×ÔÉ󔣬²¢ÄÜÖ±½Ó²Ù×÷³ÌÐòµÄÄÚ²¿ÊôÐÔ¡£ÀýÈ磬ʹÓÃËüÄÜ»ñµÃ Java ÀàÖи÷³ÉÔ±µÄÃû³Æ²¢ÏÔʾ³öÀ´¡£
Java µÄÕâÒ»ÄÜÁ¦ÔÚʵ¼ÊÓ¦ÓÃÖÐÒ²ÐíÓõò»ÊǺܶ࣬µ«ÊÇÔÚÆäËüµÄ³ÌÐòÉè¼ÆÓïÑÔÖиù±¾¾Í²»´æÔÚÕâÒ»ÌØÐÔ¡£ÀýÈ磬Pascal¡¢C ......

JavaÖÐequalºÍ==µÄ±È½Ï[zz]

×î½ü¿´µ½Ò»¸öÍøÓѹØÓÚ==ºÍequals ×öµÄ×ܽᣬ·ÖÏíÒ»ÏÂ
javaÖÐequals·½·¨ºÍ“==”µÄÇø±ð£º
equals ·½·¨ÊÇ java.lang.Object ÀàµÄ·½·¨¡£
ÓÐÁ½ÖÖÓ÷¨ËµÃ÷£º
£¨1£©¶ÔÓÚ×Ö·û´®±äÁ¿À´Ëµ£¬Ê¹ÓÓ==”ºÍ“equals()”·½·¨±È½Ï×Ö·û´®Ê±£¬Æä±È½Ï·½·¨²»Í¬¡£
“==”±È½ÏÁ½¸ö±äÁ¿±¾ÉíµÄÖµ£¬¼ ......

java ±È½ÏÆ÷µÄʹÓÃ

¶ÔÓÚÒ»¸öʵÏÖÁËComparable½Ó¿ÚµÄ¶ÔÏ󣬸ýӿÚÖ»ÄÜʵÏÖÒ»´Î¡£Èç¹ûÔÚÒ»¸ö¼¯ºÏÀïÃæÐèҪʹÓÃidÅÅÐò£¬¶øÔÚÁíÍâÒ»¸ö¼¯ºÏÀïÐèÒª°´Ãû×ÖÅÅÐòÕâʱ¾ÍÐèÒªÔÚÕâ¸ö¼¯ºÏÀïÃæÖ¸¶¨±È½ÏÆ÷¡£
Comparable½Ó¿ÚÉùÃ÷ÁËcompareTo(Object o)·½·¨
Comparator ½Ó¿ÚÉùÃ÷ÁËcompare(Object o1,Object o2)·½·¨
eg:
µÚÒ»¸öÊ÷¼¯ÊÇ°´ÕÕ¶ÔÏóĬÈϵÄidÅÅÐò£¬µ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ