java±ÊÊÔ»ã×Ü£¨2£©
41¡¢ÊÇ·ñ¿ÉÒԼ̳ÐStringÀà?
StringÀàÊÇfinalÀà¹Ê²»¿ÉÒԼ̳С£
42¡¢swtichÊÇ·ñÄÜ×÷ÓÃÔÚbyteÉÏ£¬ÊÇ·ñÄÜ×÷ÓÃÔÚlongÉÏ£¬ÊÇ·ñÄÜ×÷ÓÃÔÚStringÉÏ?
switch£¨expr1£©ÖУ¬expr1ÊÇÒ»¸öÕûÊý±í´ïʽ¡£Òò´Ë´«µÝ¸ø switch ºÍ case Óï¾äµÄ²ÎÊýÓ¦¸ÃÊÇ int¡¢ short¡¢ char »òÕß byte¡£long,string ¶¼²»ÄÜ×÷ÓÃÓÚswtich¡£
43¡¢try {}ÀïÓÐÒ»¸öreturnÓï¾ä£¬ÄÇô½ô¸úÔÚÕâ¸ötryºóµÄfinally {}ÀïµÄcode»á²»»á±»Ö´ÐУ¬Ê²Ã´Ê±ºò±»Ö´ÐУ¬ÔÚreturnÇ°»¹ÊǺó?
»áÖ´ÐУ¬ÔÚreturnÇ°Ö´ÐС£
44¡¢±à³ÌÌâ: ÓÃ×îÓÐЧÂʵķ½·¨Ëã³ö2³ËÒÔ8µÈ춼¸?
2 << 3
45¡¢Á½¸ö¶ÔÏóÖµÏàͬ(x.equals(y) == true)£¬µ«È´¿ÉÓв»Í¬µÄhash code£¬Õâ¾ä»°¶Ô²»¶Ô?
²»¶Ô£¬ÓÐÏàͬµÄhash code¡£
46¡¢µ±Ò»¸ö¶ÔÏó±»µ±×÷²ÎÊý´«µÝµ½Ò»¸ö·½·¨ºó£¬´Ë·½·¨¿É¸Ä±äÕâ¸ö¶ÔÏóµÄÊôÐÔ£¬²¢¿É·µ»Ø±ä»¯ºóµÄ½á¹û£¬ÄÇôÕâÀïµ½µ×ÊÇÖµ´«µÝ»¹ÊÇÒýÓô«µÝ?
ÊÇÖµ´«µÝ¡£Java ±à³ÌÓïÑÔÖ»ÓÐÖµ´«µÝ²ÎÊý¡£µ±Ò»¸ö¶ÔÏóʵÀý×÷Ϊһ¸ö²ÎÊý±»´«µÝµ½·½·¨ÖÐʱ£¬²ÎÊýµÄÖµ¾ÍÊǶԸöÔÏóµÄÒýÓ᣶ÔÏóµÄÄÚÈÝ¿ÉÒÔÔÚ±»µ÷Óõķ½·¨Öиı䣬µ«¶ÔÏóµÄÒýÓÃÊÇÓÀÔ¶²»»á¸Ä±äµÄ¡£
47¡¢µ±Ò»¸öÏ߳̽øÈëÒ»¸ö¶ÔÏóµÄÒ»¸ösynchronized·½·¨ºó£¬ÆäËüÏß³ÌÊÇ·ñ¿É½øÈë´Ë¶ÔÏóµÄÆäËü·½·¨?
²»ÄÜ£¬Ò»¸ö¶ÔÏóµÄÒ»¸ösynchronized·½·¨Ö»ÄÜÓÉÒ»¸öÏ̷߳ÃÎÊ¡£
48¡¢±à³ÌÌâ: дһ¸öSingleton³öÀ´¡£
SingletonģʽÖ÷Òª×÷ÓÃÊDZ£Ö¤ÔÚJavaÓ¦ÓóÌÐòÖУ¬Ò»¸öÀàClassÖ»ÓÐÒ»¸öʵÀý´æÔÚ¡£
Ò»°ãSingletonģʽͨ³£Óм¸ÖÖÖÖÐÎʽ:
µÚÒ»ÖÖÐÎʽ: ¶¨ÒåÒ»¸öÀ࣬ËüµÄ¹¹Ô캯ÊýΪprivateµÄ£¬ËüÓÐÒ»¸östaticµÄprivateµÄ¸ÃÀà±äÁ¿£¬ÔÚÀà³õʼ»¯Ê±ÊµÀý»°£¬Í¨¹ýÒ»¸öpublicµÄgetInstance·½·¨»ñÈ¡¶ÔËüµÄÒýÓÃ,¼Ì¶øµ÷ÓÃÆäÖеķ½·¨¡£
public class Singleton {
private Singleton(){}
¡¡¡¡ //ÔÚ×Ô¼ºÄÚ²¿¶¨Òå×Ô¼ºÒ»¸öʵÀý£¬ÊDz»ÊǺÜÆæ¹Ö£¿
¡¡¡¡ //×¢ÒâÕâÊÇprivate Ö»¹©ÄÚ²¿µ÷ÓÃ
¡¡¡¡ private static Singleton instance = new Singleton();
¡¡¡¡ //ÕâÀïÌṩÁËÒ»¸ö¹©Íⲿ·ÃÎʱ¾classµÄ¾²Ì¬·½·¨£¬¿ÉÒÔÖ±½Ó·ÃÎÊ¡¡¡¡
¡¡¡¡ public static Singleton getInstance() {
¡¡¡¡¡¡¡¡&nb
Ïà¹ØÎĵµ£º
һЩ³õѧJAVAµÄÅóÓÑ¿ÉÄÜ»áÓöµ½JAVAµÄÊý¾ÝÀàÐÍÖ®¼äת»»µÄ¿àÄÕ£¬ÀýÈ磬ÕûÊýºÍfloat,doubleÐÍÖ®¼äµÄת»»£¬ÕûÊýºÍStringÀàÐÍÖ®¼äµÄת»»£¬ÒÔ¼°´¦Àí¡¢ÏÔʾʱ¼ä·½ÃæµÄÎÊÌâµÈ¡£ÏÂÃæ±ÊÕ߾Ϳª·¢ÖеÄһЩÌå»á½éÉܸø´ó¼Ò¡£
ÎÒÃÇÖªµÀ£¬JavaµÄÊý¾ÝÀàÐÍ·ÖΪÈý´óÀ࣬¼´²¼¶ûÐÍ¡¢×Ö·ûÐͺÍÊýÖµÐÍ£¬¶øÆäÖÐÊýÖµÐÍÓÖ·ÖΪÕûÐͺ͸¡µãÐÍ£»Ïà¶Ô ......
ÎÒÃÇÀ´½éÉÜһϠ£½£½ºÍequals()µÄÇø±ð£¬£½£½ÊÇÏàµÈ£¬equals()Ò²ÊÇÏàµÈ¡£ÕâÁ½¸ö´ÊµÄÇø±ðÊÇʲôÄØ£¿ÕâÊÇÕÒ¹¤×÷ʱºÜ¶àÃæÊÔ¹ÙµÄÎÊÌâ¡£ÎÒÃÇÀ´½â´ðһϡ£Ê×ÏÈÎÒÃÇ¿´Õâô¸öÀý×Ó¡£Êµ¼ù£º
public class TestEquals {
public static void main(String[] args) {
MyDate date1 = new MyDate(14, 3, 1976);
MyDate date2 = ne ......
來Ô´£ºhttp://www.blogjava.net/oxidy/articles/213105.html
1.°üÃüÃû:È«²¿×ÖĸСд:cn.package.bean
2.ÀàÃüÃû:µ¥´ÊµÄÊ××Öĸ´óд:SimpleBean
3.ÊôÐÔÃû³Æ:µÚÒ»¸öµ¥´ÊµÄÊ××ÖĸСд,Ö®ºóÿ¸öµ¥´ÊµÄÊ××Öĸ´óдstudentName
4.·½·¨ÃüÃû:ÓëÊôÐÔÃüÃûÏàͬ:public
void sayHello()
5.³£Á¿ÃüÃû:È«²¿µ¥´Ê´óд:final S ......
±ØÐëÓÃthis¹Ø¼ü×ÖµÄÈýÖÖÇé¿ö:
1.ÎÒÃÇÏëͨ¹ý¹¹Ôì·½·¨½«Íⲿ´«ÈëµÄ²ÎÊý¸³Öµ¸ø³ÉÔ±±äÁ¿,¶ø¹¹Ôì·½·¨µÄÐÎʽ²ÎÊýÓëÀà³ÉÔ±µÄ±äÁ¿ÃûÏàͬ,Õâʱ¾ÍÐèÒªthisÕâ¸ö¹Ø¼ü×ÖÀ´Çø±ð¾Ö²¿±äÁ¿ÓëÀà±äÁ¿;
2.¼ÙÉèÓÐÒ»¸öÈÝÆ÷ÀàºÍÒ»¸ö²¿¼þÀà,ÔÚÈÝÆ÷ÀàµÄij¸ö·½·¨ÖÐÒª´´½¨²¿¼þÀàµÄʵÀý¶ÔÏó,¶ø²¿¼þÀàµÄ¹¹Ôì·½·¨Òª½ÓÊÕÒ»¸ö´ú±íÆäËùÔÚÈÝÆ÷µÄ²ÎÊý,ÕâÊ±Ò²Ò ......
1.FileÀàΪ¹ÜÀíÎļþºÍĿ¼ÌṩÁË·½·¨£¬Æä¶ÔÏó±íʾһ¸öÎļþ»òÕßĿ¼¡£ËüÌṩÁËÈô¸É·½·¨¶ÔÎļþ»òÎļþ¼Ð½øÐвÙ×÷¡£ÆäÖеÄlist()·½·¨ºÍlistFiles()·½·¨¿ÉÒÔÆ𵽶¨Î»Ìض¨ÎļþµÄ×÷Óá£
2.ObjectÀ࣬ÊÇËùÓÐJavaÀàµÄ×æÏÈ£¬ÈôÒ»¸öÀàÉùÃ÷ʱûÓаüº¬extends¹Ø¼ü×Ö£¬ÔòÆäÖ±½Ó¼Ì³ÐÓÚObjetcÀà¡£ÆäÖÐÓÐÐí¶àÖØÒª·½·¨£º
equals(),notify(), ......