Effective Java ѧϰ±Ê¼Ç£¨5£©
¾¡Á¿¸´ÓöÔÏ󣬶ø²»ÊÇ´´½¨ÐµĶÔÏó£¬ÌرðÊǵ±Ò»¸ö¶ÔÏóÊÇimmutable£¨²»¿É¸Ä±ä£©µÄʱºò¡£ ÈçString¶ÔÏó£¬ String s= new String(¡°String¡±); ǧÍò²»ÒªÕâÑù×ö£¬ÒòΪÕâÀïʵ¼ÊÉÏ´´½¨ÁËÁ½¸ö¶ÔÏó¡£ Òª±ÜÃâ³öÏÖÕâÑùµÄÇé¿ö£¬ 1ÊÇ¿ÉÒÔÓþ²Ì¬¹¤³§º¯Êý£¬À´½â¾ö£¬ÈçÀà¿âÖеÄBoolean.valueOf(¡°true¡±)£¬ÕâÖÖ·½Ê½ÒªÓÅÓÚnew Boolean(¡°true¡±); 2.ÊǾ¡Á¿¸´ÓöÔÏó¡£ ¿´ÊéÖеÄÀý×Ó¡£ public class Person {
private final Date birthDate;
public boolean isBabyBoomer() {
Calendar gmtCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
gmtCal.set(1946, Calendar.JANUARY, 1, 0, 0, 0);
Date boomStart = gmtCal.getTime();
gmtCal.set(1965, Calendar.JANUARY, 1, 0, 0, 0);
Date boomEnd = gmtCal.getTime();
return birthDate.compareTo(boomStart) >= 0 && birthDate.compareTo(boomEnd) < 0;
}
} ÕâÀÿ´Îµ÷ÓÃisBabyBoomer¾Í»á´´½¨Á½¸öData¶ÔÏó£¬Ò»¸öCalendar¶ÔÏóºÍTimeZone¶ÔÏó. ¸Ä½ø°æ£º class Person {
private final Date birthDate;
private static final Date BOOM_START;
Ïà¹ØÎĵµ£º
1¡¢java.lang°ü£ºjavaµÄºËÐÄÀà¿â£¬°üº¬ÁËÔËÐÐjava³ÌÐò±Ø²»¿ÉÉÙµÄϵͳÀ࣬Èç»ù±¾Êý¾ÝÀàÐÍ¡¢»ù±¾Êýѧº¯Êý¡¢×Ö·û´®´¦Àí¡¢Ï̡߳¢Òì³£´¦ÀíÀàµÈ£¬ÏµÍ³È±Ê¡¼ÓÔØÕâ¸ö°ü
2¡¢java.io°ü£ºjavaÓïÑԵıê×¼ÊäÈë/Êä³öÀà¿â£¬Èç»ù±¾ÊäÈë/Êä³öÁ÷¡¢ÎļþÊäÈë/Êä³ö¡¢¹ýÂËÊäÈë/Êä³öÁ÷µÈµÈ
3¡¢java.util°ü£º°üº¬Èç´¦Àíʱ¼äµÄdateÀ࣬´¦Àí±ä³ÉÊý ......
À´CSDNÒ²ÓÐÒ»Äêʱ¼äÁË£¬Ò»Ö±Ã»ÓÐÔÚ×Ô¼ºµÄ¿Õ¼äÀï·¢±íÒ»µã¶«Î÷¡£
Ç°¼¸Ì죬ÎÒÅóÓÑÏëºÍÎÒÒ»Æð¸ã¸ö¶«Î÷£¬ÐèÒªÓõ½java£¬ÎÒûÓÐÒ»µãjava»ù´¡¡£Ã»°ì·¨£¬Ö»Äܹ»´ÓÍ·¿ªÊ¼ÁËѧϰ¡£
´ÓͼÊé¹Ý±§»ØÁËÁ½±¾Ê顶java2ÈëÃÅ ½ø½×ÓëÓ¦ÓÃʵÀý¡·ºÍ¡¶java me ʵÓÃÏê½â¡·¡£ÓÉÓÚÓÐCºÍC++µÄ»ù´¡£¬³õÂÔ¿´ÁËÒ»ÏÂÊ飬¶ÔÓÚÊéÖеÄÄÚÈÝ»ù±¾ÉÏ»¹ÊÇÄܹ»Àí½â ......
javaËÄÉáÎåÈë
package Test;
import java.math.BigDecimal; //ÒýÈëÕâ¸ö°ü
public class Test {
public static void main(String[] args) {
double i = 3.856;
// ÉáµôСÊýÈ¡Õû
System.out.println("ÉáµôСÊýÈ¡Õû:Math.floor(3.856)=" + (int) Math.floor(i));
......
RMI (Remote Method Invocation£¬Ô¶³Ì·½·¨µ÷ÓÃ)ÈçºÎÓÃÓÚ³ÌÐò¼äͨѶ£¬ÁíÒ»¸öÓÃÓÚͨѶµÄ¼¼ÊõÊÇRuntime.exec() ·½·¨¡£Äã¿ÉÒÔÓÃÕâ¸ö·½·¨´ÓÒ»¸öÔËÐа¢java³ÌÐòÖе÷ÓÃÁíÒ»¸ö³ÌÐò¡£Runtime.exec Ò²ÔÊÐíÄãÖ´ÐкͳÌÐòÏà¹ØµÄ²Ù×÷£¬ÀýÈç¿ØÖƳÌÐòµÄ±ê×¼ÊäÈëÊä³ö£¬µÈ´ý³ÌÐòµÄ½áÊø²¢µÃµ½ËüµÄÍ˳ö״̬¡£ÏÂÃæÊÇÒ»¸ ......