java ÍøÂç±à³Ì
ÕâÀï¶ÔÓÚ¼¸¸ö»ù±¾µÄ¸ÅÄî URL TCP UDP Socket ¾Í²»¼Ó˵Ã÷ÁË£¬ÕâÀï½ö½öÊǼǼһЩѧϰÈÕÖ¾±¸Íü¡£
1£ºÈçºÎ¶¨ÒåÏà¶Ô×ÊÔ´
¼ÙÉèÓÐÈçÏÂÁ½¸ö×ÊÔ´ £º
http://www.gamelan.com/pages/Gamelan.game.html
http://www.gamelan.com/pages/Gamelan.net.html
ÎÒÃÇ¿ÉÒÔͨ¹ýURL µÄ¹¹Ô캯ÊýÀ´¶¨Òå×ÊÔ´£¬¿ÉÒÔͨ¹ýÒ»¸ö URL ¶ÔÏóÀ´¹¹ÔìÒ»¸öÏ൱×ÊÔ´ URL(URL baseURL, String relativeURL)
£¬ÈçÏ£º
URL gamelan = new URL("http://www.gamelan.com/pages/");
URL gamelanGames = new URL(gamelan, "Gamelan.game.html");
URL gamelanNetwork = new URL(gamelan, "Gamelan.net.html");
¶ÔÓÚÓÐÌØÊâ×Ö·ûµÄ url µØÖ· È磺http://foo.com/hello world/ º¬Óпոñ£¬
ÄÇôÕâÀïµÄµØÖ·ÊÇÐèÒª encode µÄ£¨URL url = new URL("http://foo.com/hello%20world");£©£¬
»òÕßÊÇͨ¹ýuri À´Éú²ú url¡£ÈçÏ£º
URI uri = new URI("http", "foo.com", "/hello world/", "");
URL url = uri.toURL();
2£º Socket ¾ÍÊÇÒ»¸öµã¶ÔµãµÄ tcp Á¬½Ó£¬·þÎñ¶Ëͨ¹ýÒ»¸ö serversocket À´¼àÌý±¾µØµÄÒ»¸ö¶Ë¿Ú sport1£¬Èç¹ûÓпͻ§¶Ësocket Á¬½ÓÉÏÀ´£¬
serversocket »áÖØÐÂÉú³ÉÒ»¸ö socket £¬Õâ¸ösocket Á¬½Ó±¾»úµÄ¶Ë¿Ú sport1 ºÍ ¿Í»§¶Ësocket µÄ¶Ë¿Ú¡£
¿Í»§¶ËÁ¬½Ó·þÎñÆ÷µÄʱºò£¬»áÁ¬½Ó·þÎñÆ÷µÄ¼àÌý¶Ë¿Ú£¬¶ø¿Í»§¶ËΪÁËÄܹ»Ê¹µÃ·þÎñ¶ËÄܹ»Á¬½Óµ½¿Í»§¶Ë£¬¿Í»§¶ËsocketÒ²»á°ó¶¨Ò»¸ö±¾µØ¶Ë¿Ú£¬
Õâ¸ö¶Ë¿ÚÒ»°ãÀ´Ëµ¶¼ÊÇϵͳ·ÖÅäµÄ£¬¶øÇÒ·þÎñ¶ËµÄÉú³ÉµÄ socket Ò²»áÁ¬½ÓÕâ¸ö¿Í»§¶Ë»úÆ÷µÄϵͳ·ÖÅäµÄ¶Ë¿ÚÀ´½¨Á¢Á¬½Ó¡£
ÕâÀïµÄ ·þÎñ¶Ë serversocket ÔÚ¼àÌýµ½¿Í»§¶ËsocketÁ¬½Óºó Éú³ÉÒ»¸ö ·þÎñ¶ËµÄÁ¬½Ó¿Í»§¶ËµÄsocket£¬
ÕâÀïÕë¶Ôÿ¸öÁ¬½ÓÉú³ÉµÄsocketÀ´²úÉúÒ»¸öÏ̴߳¦ÀíÒµÎñµÄ»°£¬ÄÇôÕâ¸ö server ¾Í¿ÉÒÔÖ§³Ö¶à¸ö¿Í»§¶ËÁË¡£
3: UDP ÊDzÉÓÃÊý¾Ý°üµÄÐÎʽ·¢ËÍ¡£ÓкܶàµÄ·À»ðǽºÍ ·ÓÉÆ÷ÅäÖÃÓв»½ÓÊÜUDPÊý¾Ý°ü£¬Èç¹û³öÏÖÁ¬½Ó²»ÉÏ·þÎñÆ÷£¬»òÕß˵·þÎñ¶Ë½ÓÊÕ²»µ½ UDPÊý¾Ý°ü£¬ÅŲéÍøÂçµÄʱºò¿ÉÒÔºËʵһÏÂÕâ¸öÍøÂçÅäÖá£
UDP Êý¾Ý°üÊÇÒ»¸ö×ÔÑ°Ö·µÄÊý¾Ý°ü£¬Ëû°üº¬ÓÐÒªµ½´ïµÄÄ¿µÄµØÐÅÏ¢£¬Æäµ½´ïµÄʱ¼äºÍ˳ÐòºÍÄÚÈÝÊDz»±»±£Ö¤µÄ¡£Ëü²»ÏñTCPÄÇÑùÊǽ¨Á¢Ò»¸ö¿É¿¿µÄÁ´Â·Í¨µÀ´«Ê
Ïà¹ØÎĵµ£º
Reflection ÊÇ Java ³ÌÐò¿ª·¢ÓïÑÔµÄÌØÕ÷Ö®Ò»£¬ËüÔÊÐíÔËÐÐÖÐµÄ Java ³ÌÐò¶Ô×ÔÉí½øÐмì²é£¬»òÕß˵“×ÔÉ󔣬²¢ÄÜÖ±½Ó²Ù×÷³ÌÐòµÄÄÚ²¿ÊôÐÔ¡£ÀýÈ磬ʹÓÃËüÄÜ»ñµÃ Java ÀàÖи÷³ÉÔ±µÄÃû³Æ²¢ÏÔʾ³öÀ´¡£
Java µÄÕâÒ»ÄÜÁ¦ÔÚʵ¼ÊÓ¦ÓÃÖÐÒ²ÐíÓõò»ÊǺܶ࣬µ«ÊÇÔÚÆäËüµÄ³ÌÐòÉè¼ÆÓïÑÔÖиù±¾¾Í²»´æÔÚÕâÒ»ÌØÐÔ¡£ÀýÈ磬Pascal¡¢C ......
ÀàÐÍת»»×ܽ᣺
1.ÔÐÍÊý¾Ýbyte,short,int,long,float,double,char,boolean,СÀàÐÍÊý¾Ý¿ÉÒÔÖ±½Ó¸³¸ø´óÀàÐÍÊý¾ÝÀýÈç
int a=1;byte b=2;short c=3;float d=3;double e=4;char f='a';boolean g=true;long l=10;
c=b;
a=f;
d=a;
e=d;
byteÐÍÊý¾Ý²»ÄÜÖ±½Ó¸³¸øcharÐÍÊý¾Ý£¬ÒòΪbyte±íʾµÄÊÇ8λÓзûºÅÊý£¬¶øchar±íʾµ ......
¶ÔÓÚÒ»¸öʵÏÖÁËComparable½Ó¿ÚµÄ¶ÔÏ󣬸ýӿÚÖ»ÄÜʵÏÖÒ»´Î¡£Èç¹ûÔÚÒ»¸ö¼¯ºÏÀïÃæÐèҪʹÓÃidÅÅÐò£¬¶øÔÚÁíÍâÒ»¸ö¼¯ºÏÀïÐèÒª°´Ãû×ÖÅÅÐòÕâʱ¾ÍÐèÒªÔÚÕâ¸ö¼¯ºÏÀïÃæÖ¸¶¨±È½ÏÆ÷¡£
Comparable½Ó¿ÚÉùÃ÷ÁËcompareTo(Object o)·½·¨
Comparator ½Ó¿ÚÉùÃ÷ÁËcompare(Object o1,Object o2)·½·¨
eg:
µÚÒ»¸öÊ÷¼¯ÊÇ°´ÕÕ¶ÔÏóĬÈϵÄidÅÅÐò£¬µ ......