JAVA´úÂë±àд¹æ·¶
¸½Â¼A: Java±àÂë¹æ·¶
Ò»¡¢ JavaÃüÃûµÄÒ»°ãÐÔÖ¸µ¼
1. ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£ÊôÐÔ£¨³ÉÔ±±äÁ¿£©¡¢·½·¨¡¢¶ÔÏó±äÁ¿ÒÔ¼°ËùÓбêʶ·û£¨ÈçÐÎʽ²Î
Êý¡¢Êµ¼Ê²ÎÊý¡¢¾Ö²¿±äÁ¿£©µÄÊ××ÖĸӦСд£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æ𣬶ø
ÇÒ´óдÖм䵥´ÊµÄÊ××Öĸ¡£
ÀýÈ磺ÀàÃû£ºThisIsAClassName ÊôÐÔ»ò·½·¨Ãû£ºthisIsMethodOrFieldName
¶ÔÏó±äÁ¿£ºthisIsAClassVariable
2. Java °ü£¨Package£©ÊôÓÚÒ»ÖÖÌØÊâÇé¿ö£¬ËüÃÇÈ«¶¼ÊÇСд×Öĸ£¬¼´±ãÖмäµÄµ¥´ÊÒàÊÇÈç
´Ë¡£¶ÔÓÚÈ«¾Ö°ü£¬½«ÄãµÄ Internet ÓòÃû·´×ª²¢½ÓÉÏ°üÃû£¬
ÀýÈ磺cn.edu.usst.dingyuewei.package
ÁíÍ⣬package ÐÐÒªÔÚimport ÐÐ֮ǰ£¬import Öбê×¼µÄ°üÃûÒªÔÚ±¾µØµÄ°üÃûÖ®
Ç°£¬¶øÇÒ°´ÕÕ×Öĸ˳ÐòÅÅÁС£Èç¹û import ÐÐÖаüº¬ÁËͬһ¸ö°üÖеIJ»Í¬×ÓĿ¼£¬ÔòÓ¦
¸ÃÓà * À´´¦Àí¡£ÀýÈç
package hotlava.net.stats;
import java.io.*;
import java.util.Observable;
import hotlava.util.Application;
ÕâÀï java.io.* ÊÇÓÃÀ´´úÌæInputStream and OutputStream µÄ¡£
3. ½Ó¿Ú£¨Interface£©£º²ÉÓÃÍêÕûµÄÓ¢ÎÄÃèÊö·û˵Ã÷½Ó¿Ú·â×°£¬ËùÓе¥´ÊµÄµÚÒ»¸ö×Öĸ´ó
д¡£Ï°¹ßÉÏ£¬Ãû×ÖºóÃæ¼ÓÉϺó׺ able£¬ ible »òÕß er¡£
ÀýÈ磺Contactable£¬Prompter¡£
4. ×é¼þ£¨Component£©Ê¹ÓÃÍêÕûµÄÓ¢ÎÄÃèÊöÀ´ËµÃ÷×é¼þµÄÓÃ;£¬Ä©¶ËÓ¦½ÓÉÏ×é¼þÀàÐÍ¡£
ÀýÈ磺okButton£¬customerList£¬fileMenu¡£
5. ÀàÖг£Ó÷½·¨µÄÃüÃû£º
l ÀàµÄ»ñÈ¡·½·¨£¨Ò»°ã¾ßÓзµ»ØÖµ£©Ò»°ãÒªÇó±»·½·¨ÃûʹÓñ»·ÃÎÊ×Ö¶ÎÃû£¬Ç°Ãæ¼ÓÉÏ
ǰ׺get£¬ÈçgetFirstName(), getLastName()¡£
l ÀàµÄ²¼¶ûÐ͵ÄÅжϷ½·¨Ò»°ãÒªÇó·½·¨ÃûʹÓõ¥´Ê is ×öǰ׺£¬ÈçisPersistent(),
isString()¡£»òÕßʹÓþßÓÐÂß¼ÒâÒåµÄµ¥´Ê£¬ÀýÈçequal »òequals
l ÀàµÄÉèÖ÷½·¨£¨Ò»°ã·µ»ØÀàÐÍΪvoid£©£º±»·ÃÎÊ×Ö¶ÎÃûµÄÇ°Ãæ¼ÓÉÏǰ׺ set£¬Èç
setFirstName(),setLastName()£¬setWarpSpeed()¡£
l ÀàµÄÆÕͨ·½·¨Ò»°ã²ÉÓÃÍêÕûµÄÓ¢ÎÄÃèÊö˵Ã÷³ÉÔ±·½·¨¹¦ÄÜ£¬µÚÒ»¸öµ¥´Ê¾¡¿ÉÄܲÉÓÃ
Ò»¸öÉú¶¯µÄ¶¯´Ê£¬µÚÒ»¸ö×ÖĸСд£¬Èç openFile(), addAccount()¡£
l ¹¹Ôì·½·¨Ó¦¸ÃÓõÝÔöµÄ·½Ê½Ð´£¨±ÈÈ磺²ÎÊý¶àµÄдÔÚºóÃ棩¡£
ÀýÈ磺
public CounterSet(){}
public CounterSet(int size){ this.size = size;}
l toString ·½·¨£ºÒ»°ãÇé¿öÏ£¬Ã¿Ò»¸öÀ඼Ӧ¸Ã¶¨ÒåtoString ·½·¨£¬Æä¸ñʽΪ£º
public String toString() {…}
l Ò»°ãÓ¦¿¼ÂÇÖÃÈëÒ»¸ömain()·½·¨£¬ÆäÖаüº¬ÓÃÓÚ²âÊÔÄǸöÀàµÄ´úÂ룬Èç¹û°üº¬ÁË
Ïà¹ØÎĵµ£º
ÔÚ Java ³ÌÐòÖÐʹÓöàÏß³ÌÒª±ÈÔÚ C »ò C++ ÖÐÈÝÒ׵ö࣬ÕâÊÇÒòΪ Java ±à³ÌÓïÑÔÌṩÁËÓïÑÔ¼¶µÄÖ§³Ö¡£±¾ÎÄͨ¹ý¼òµ¥µÄ±à³ÌʾÀýÀ´ËµÃ÷ Java ³ÌÐòÖеĶàÏß³ÌÊǶàôֱ¹Û¡£¶ÁÍê±¾ÎÄÒÔºó£¬Óû§Ó¦¸ÃÄܹ»±àд¼òµ¥µÄ¶àÏ̳߳ÌÐò¡£
¡¡¡¡ÎªÊ²Ã´»áÅŶӵȴý?
¡¡¡¡ÏÂÃæµÄÕâ¸ö¼òµ¥µÄ Java ³ÌÐòÍê³ÉËÄÏî²»Ïà¹ØµÄÈÎÎñ¡£ÕâÑùµ ......
Java´úÂë
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
......
·ºÐÍ£¨Generic type »òÕßgenerics£©ÊÇ¶Ô Java ÓïÑÔµÄÀàÐÍϵͳµÄÒ»ÖÖÀ©Õ¹£¬ÒÔÖ§³Ö´´½¨¿ÉÒÔ°´ÀàÐͽøÐвÎÊý»¯µÄÀà¡£¿ÉÒÔ°ÑÀàÐͲÎÊý¿´×÷ÊÇʹÓòÎÊý»¯ÀàÐÍʱָ¶¨µÄÀàÐ͵ÄÒ»¸öռλ·û£¬¾ÍÏñ·½·¨µÄÐÎʽ²ÎÊýÊÇÔËÐÐʱ´«µÝµÄÖµµÄռλ·ûÒ»Ñù¡£
¿ÉÒÔÔÚ¼¯ºÏ¿ò¼Ü£¨Collection framework£©Öп´µ½·ºÐ͵Ķ¯»ú¡£ÀýÈ磬MapÀàÔÊÐíÄúÏòÒ»¸öMapÌí ......
java.util°üÖоͰüº¬ÁËһϵÁÐÖØÒªµÄ¼¯ºÏÀ࣬¶ø¶ÔÓÚ¼¯ºÏÀ࣬Ö÷ÒªÐèÒªÕÆÎյľÍÊÇËüµÄÄÚ²¿½á¹¹£¬ÒÔ¼°±éÀú¼¯ºÏµÄµü´úģʽ¡£
½Ó¿Ú£ºCollection
ËùÓм¯ºÏÀàµÄ¸ùÀàÐÍ£¬Ö÷ÒªµÄÒ»¸ö½Ó¿Ú·½·¨£ºboolean add(Ojbect c)Ëä·µ»ØµÄÊÇboolean£¬µ«²»ÊDZíʾÌí¼Ó³É¹¦Óë·ñ£¬ÒòΪCollection¹æ¶¨£ºÒ»¸ö¼¯ºÏ¾Ü¾øÌí¼ÓÕâ¸öÔªËØ£¬ÎÞÂÛʲôÔÒò£¬¶¼± ......