JAVA¼¯ºÏ
Vector : »ùÓÚArrayµÄList£¬Æäʵ¾ÍÊÇ·â×°ÁËArrayËù²»¾ß±¸µÄһЩ¹¦ÄÜ·½±ãÎÒÃÇʹÓã¬Ëü²»¿ÉÄÜ×ßÈëArrayµÄÏÞÖÆ¡£ÐÔÄÜÒ²¾Í²»¿ÉÄÜ
³¬Ô½Array¡£ËùÒÔ£¬ÔÚ¿ÉÄܵÄÇé¿öÏ£¬ÎÒÃÇÒª¶àÔËÓÃArray¡£ÁíÍâºÜÖØÒªµÄÒ»µã¾ÍÊÇVector“sychronized”µÄ£¬Õâ¸öÒ²ÊÇVectorºÍ
ArrayListµÄΨһµÄÇø±ð¡£
ArrayList£ºÍ¬VectorÒ»ÑùÊÇÒ»¸ö»ùÓÚArrayÉϵÄÁ´±í£¬µ«ÊDz»Í¬µÄÊÇArrayList²»ÊÇͬ²½µÄ¡£ËùÒÔÔÚÐÔÄÜÉÏÒª±ÈVectorÓÅԽһЩ£¬µ«
Êǵ±ÔËÐе½¶àÏ̻߳·¾³ÖÐʱ£¬¿ÉÐèÒª×Ô¼ºÔÚ¹ÜÀíÏ̵߳Äͬ²½ÎÊÌâ¡£
LinkedList£ºLinkedList²»Í¬ÓÚÇ°ÃæÁ½ÖÖList£¬Ëü²»ÊÇ»ùÓÚArrayµÄ£¬ËùÒÔ²»ÊÜArrayÐÔÄܵÄÏÞÖÆ¡£Ëüÿһ¸ö½Úµã£¨Node£©¶¼°üº¬Á½·½
ÃæµÄÄÚÈÝ£º1.½Úµã±¾ÉíµÄÊý¾Ý£¨data£©£»2.ÏÂÒ»¸ö½ÚµãµÄÐÅÏ¢£¨nextNode£©¡£ËùÒÔµ±¶ÔLinkedList×öÌí¼Ó£¬É¾³ý¶¯×÷µÄʱºò¾Í²»ÓÃÏñ
»ùÓÚArrayµÄListÒ»Ñù£¬±ØÐë½øÐдóÁ¿µÄÊý¾ÝÒƶ¯¡£Ö»Òª¸ü¸ÄnextNodeµÄÏà¹ØÐÅÏ¢¾Í¿ÉÒÔʵÏÖÁË¡£Õâ¾ÍÊÇLinkedListµÄÓÅÊÆ¡£
List×ܽ᣺
1. ËùÓеÄListÖÐÖ»ÄÜÈÝÄɵ¥¸ö²»Í¬ÀàÐ͵ĶÔÏó×é³ÉµÄ±í£¬¶ø²»ÊÇKey£Value¼üÖµ¶Ô¡£ÀýÈ磺[ tom,1,c ]£»
2. ËùÓеÄListÖпÉÒÔÓÐÏàͬµÄÔªËØ£¬ÀýÈçVectorÖпÉÒÔÓÐ [ tom,koo,too,koo ]£»
3. ËùÓеÄListÖпÉÒÔÓÐnullÔªËØ£¬ÀýÈç[ tom,null,1 ]£»
4. »ùÓÚArrayµÄList£¨Vector£¬ArrayList£©Êʺϲéѯ£¬¶øLinkedList£¨Á´±í£©ÊʺÏÌí¼Ó£¬É¾³ý²Ù×÷¡£
=========================ÎÒÊÇÎ޵зָîÏß=========================================
HashSet£ºËäÈ»SetͬList¶¼ÊµÏÖÁËCollection½Ó¿Ú£¬µ«ÊÇËûÃǵÄʵÏÖ·½Ê½È´´ó²»Ò»Ñù¡£List»ù±¾É϶¼ÊÇÒÔArrayΪ»ù´¡¡£µ«ÊÇSetÔòÊÇ
ÔÚHashMapµÄ»ù´¡ÉÏÀ´ÊµÏֵģ¬Õâ¸ö¾ÍÊÇSetºÍListµÄ¸ù±¾Çø±ð¡£HashSetµÄ´æ´¢·½Ê½ÊÇ°ÑHashMapÖеÄKey×÷ΪSetµÄ¶ÔÓ¦´æ´¢Ïî¡£¿´¿´
HashSetµÄadd£¨Object obj£©·½·¨µÄʵÏ־ͿÉÒÔһĿÁËÈ»ÁË¡£
public boolean add(Object obj)
{
return map.put(obj, PRESENT) == null;
}
Õâ¸öÒ²ÊÇΪʲôÔÚSetÖв»ÄÜÏñÔÚListÖÐÒ»ÑùÓÐÖظ´µÄÏîµÄ¸ù±¾ÔÒò£¬ÒòΪHashMapµÄkeyÊDz»ÄÜÓÐÖظ´µÄ¡£
LinkedHashSet£ºHashSetµÄÒ»¸ö×ÓÀ࣬һ¸öÁ´±í¡£
TreeSet£ºSortedSetµÄ×ÓÀ࣬Ëü²»Í¬ÓÚHashSetµÄ¸ù±¾¾ÍÊÇTreeSetÊÇÓÐÐòµÄ¡£ËüÊÇͨ¹ýSortedMapÀ´ÊµÏֵġ£
Set×ܽ᣺
1. SetʵÏֵĻù´¡ÊÇMap£¨HashMap£©£»
2. SetÖеÄÔªËØÊDz»ÄÜÖظ´µÄ£¬Èç¹ûʹÓÃadd(Object obj)·½·¨Ìí¼ÓÒѾ´æÔڵĶÔÏó£¬Ôò»á¸²¸ÇÇ°ÃæµÄ¶ÔÏó
=========================ÎÒÊÇÎ޵зָîÏß===========
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
Java ¶ÔÎļþ½øÐжÁд²Ù×÷µÄÀý×Ӻܶ࣬ÈóõѧÕ߸е½Ê®·ÖÀ§»ó£¬ÎÒ¾õµÃÓбØÒª½«¸÷ÖÖ·½·¨½øÐÐ
Ò»´Î·ÖÎö£¬¹éÀ࣬ÀíÇ岻ͬ·½·¨Ö®¼äµÄÒìͬµã¡£
Ò»£®ÔÚ JDK 1.0 ÖУ¬Í¨³£ÊÇÓà InputStream & OutputStream ÕâÁ½¸ö»ùÀàÀ´½øÐжÁд²Ù×÷µÄ¡£
InputStream ÖÐµÄ FileInputStream ÀàËÆÒ»¸öÎļþ¾ä±ú£¬Í¨¹ýËüÀ´¶ÔÎļþ½øÐвÙ×÷£¬ÀàËÆ ......
3.Sun HotSpot
¡¡¡¡1.4.1 JVM¶Ñ´óСµÄµ÷Õû
¡¡¡¡Sun HotSpot 1.4.1ʹÓ÷ִúÊÕ¼¯Æ÷£¬Ëü°Ñ¶Ñ·ÖΪÈý¸öÖ÷ÒªµÄÓò£ºÐÂÓò¡¢¾ÉÓòÒÔ¼°ÓÀ¾ÃÓò¡£JvmÉú³ÉµÄËùÓÐжÔÏó·ÅÔÚÐÂÓòÖС£Ò»µ©¶ÔÏó¾ÀúÁËÒ»¶¨ÊýÁ¿µÄÀ¬»øÊÕ¼¯Ñ»·ºó£¬±ã»ñµÃʹÓÃÆÚ²¢½øÈë¾ÉÓò¡£ÔÚÓÀ¾ÃÓòÖÐjvmÔò´æ´¢classºÍmethod¶ÔÏó¡£¾ÍÅäÖöøÑÔ£¬ÓÀ¾ÃÓòÊÇÒ»¸ö¶ÀÁ¢Óò²¢ÇÒ²» ......
import java.io.*;
class FileTest
{
public static void main(String[] args) throws Exception
{
//File f=new File("1.txt");
//f.createNewFile();
//f.mkdir();
//File f=new File("E:\\JavaLesson\\Lesson7\\1.txt");//ÔÚWindowsϵͳÏÂ,Óþø¶Ô ......
C++ÓëJavaµÄÓï·¨Çø±ð
Ê×ÏÈ£¬Á½¸ö´óµÄ²»Í¬ÊÇÖ÷º¯ÊýºÍÔõÑù±àÒëµÄ²»Í¬£¬½ÓÏÂÀ´ÊÇÐí¶àСµÄÇø±ð¡£
main º¯Êý
C++
//×ÔÓɸ¡¶¯µÄº¯Êý
int main( int argc, char* argv[])
{
printf( "Hello, world" );
}
Java
// ÿ¸öº¯Êý¶¼±ØÐëÊÇÒ»¸öÀàµÄÒ»²¿·Ö;µ±java <class>ÔËÐÐÊÇÒ»¸öÌض¨ÀàµÄÖ÷º¯Êý»á±»µ÷ ......