´«ÖDz¥¿Í2009 12 24 Èý¡¢java»ù´¡¼ÓÇ¿(3)
Ò»¡¢·ºÐÍ(Generic)
JDK5ÒÔÇ°£¬¶ÔÏó±£´æµ½¼¯ºÏÖоͻáʧȥÆäÌØÐÔ£¬È¡³öʱͨ³£Òª³ÌÐòÔ±ÊÖ¹¤½øÐÐÀàÐ͵ÄÇ¿ÖÆת»»£¬ÕâÑù²»¿É±ÜÃâ¾Í»áÒý·¢³ÌÐòµÄһЩ°²È«ÐÔÎÊÌâ
Ø·ºÐεÄ×÷Óãº
JDK5ÖеķºÐÎÔÊÐí³ÌÐòÔ±ÔÚ±àд¼¯ºÏ´úÂëʱ£¬¾ÍÏÞÖƼ¯ºÏµÄ´¦ÀíÀàÐÍ£¬´Ó¶ø°ÑÔÀ´³ÌÐòÔËÐÐʱ¿ÉÄÜ·¢ÉúÎÊÌ⣬ת±äΪ±àÒëʱµÄÎÊÌ⣬ÒÔ´ËÌá¸ß³ÌÐòµÄ¿É¶ÁÐÔºÍÎȶ¨ÐÔ(ÓÈÆäÔÚ´óÐͳÌÐòÖиüΪͻ³ö)¡£
×¢Ò⣺·ºÐÍÊÇÌṩ¸øjavac±àÒëÆ÷ʹÓõģ¬ËüÓÃÓÚÏÞ¶¨¼¯ºÏµÄÊäÈëÀàÐÍ£¬ÈñàÒëÆ÷ÔÚÔ´´úÂ뼶±ðÉÏ£¬¼´µ²×¡Ïò¼¯ºÏÖвåÈë·Ç·¨Êý¾Ý¡£µ«±àÒëÆ÷±àÒëÍê´øÓзºÐεÄjava³ÌÐòºó£¬Éú³ÉµÄclassÎļþÖн«²»ÔÙ´øÓзºÐÎÐÅÏ¢£¬ÒÔ´Ëʹ³ÌÐòÔËÐÐЧÂʲ»Êܵ½Ó°Ï죬Õâ¸ö¹ý³Ì³Æ֮Ϊ“²Á³ý”¡£
Ø·ºÐ͵äÐÍÓ¦Óãº
1¡¢ ʹÓõü´úÆ÷µü´ú·ºÐμ¯ºÏÖеÄÔªËØ¡£
Eg. List<String> list = new ArrayList<String>();
list.add("Acegi");
list.add("Red5");
list.add("OpenMeettings");
Iterator<String> it = list.iterator();
while(it.hasNext()){
String bookname = it.next();
… …
}
2¡¢Ê¹ÓÃÔöÇ¿forÑ»·µü´ú·ºÐμ¯ºÏÖеÄÔªËØ¡£
Eg. for(String bookname : list){
… …
}
3¡¢´æÈ¡HashMapÖеÄÔªËØ¡£
Eg. Map<Integer,String> map = new HashMap<Integer,String>();
map.put(1, " Acegi ");
map.put(2, " Red5");
map.put(3, " OpenMeettings ");
S
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
Ḭ̈߳²È«µÄ¼¯ºÏ°üº¬2¸öÎÊÌâ
1.¶àÏ̲߳¢·¢ÐÞ¸ÄÒ» ¸ö ¼¯ºÏ Ôõô°ì£¿
2.Èç¹ûµü´úµÄ¹ý³ÌÖÐ ¼¯ºÏ ±»ÐÞ¸ÄÁËÔõô°ì£¿
a.Ò»¸öÏß³ÌÔÚµü´ú£¬ÁíÒ»¸öÏß³ÌÔÚÐÞ¸Ä
b.ÔÚͬһ¸öÏß³ÌÄÚÓÃͬһ¸öµü´úÆ÷¶ ......
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test {
public static void main(String arg[]) {
String fileName = "E:\\share\\test.txt";
File file = new File(fileName);
......