ʹÓÃÔÖÔζµÄJava ÓïÑÔ
±¾ÎÄÕª×Ô£º http://www.ibm.com/developerworks/cn/java/j-noaccent.html
ѧϰһÖÖеıà³ÌÓïÑÔ±ÈѧϰеĿÚÍ·ÓïÑÔÒªÈÝÒ׵öࡣȻ¶ø£¬ÔÚÕâÁ½ÖÖѧϰ¹ý³ÌÖУ¬¶¼Òª¸¶³ö¶îÍâµÄŬÁ¦È¥Ñ§Ï°²»´ø¿ÚÒôµØ˵ÐÂÓïÑÔ¡£Èç¹ûÄúÊìϤ C »ò C++£¬ÄÇôѧϰ Java ÓïÑÔ²¢²»À§ÄÑ£¬Õâ¾ÍÏñÊÇ»á˵ÈðµäÓïµÄÈËȥѧµ¤ÂóÓïÒ»Ñù¡£ÓïÑÔËäÓв»Í¬£¬µ«Óֱ˴˻¥Í¨¡£µ«Èô²»¹»½÷É÷£¬ÄúµÄ¿ÚÒôÿ´Î¶¼»á±©Â¶³öÄú²¢·ÇÔÉúÓïÑÔʹÓÃÕßÕâ¸öÃØÃÜ¡£
C++ ³ÌÐòÔ±ÍùÍù»á¶Ô Java ´úÂë×ö³öһЩ±äÐΣ¬¶øÕâÑùµÄ¾Ù¶¯½«ËûÃÇÓëÔÉú Java ÓïÑÔÓû§ÇåÎúµØÇø·Ö¿ªÀ´¡£ËûÃǵĴúÂë¿ÉÒÔÎÞ´íÔËÐУ¬µ«¶ÔÓÚÔÉúÓïÑÔÓû§À´Ëµ£¬¾ÍÊÇÓÐһЩµØ·½²»¶Ô¾¢¡£Òò¶øÔÉúÓïÑÔÓû§¿ÉÄÜ»áÇáÊÓ·ÇÔÉúÓû§¡£´Ó C »ò C++£¨»òÕß Basic¡¢Fortran¡¢Scheme µÈ£©×ªµ½ Java ÓïÑÔʱ£¬ÄúÐèÒª¸ù³ýһЩϰ¹ßÓÃÓ²¢¾ÀÕýijЩ·¢Òô£¬ÒÔ±ãÁ÷³©µØʹÓÃÐÂÓïÑÔ¡£
ÔÚ±¾ÎÄÖУ¬ÎÒ̽ÌÖÁËһЩÍùÍù±»ºöÊ Java ±à³Ìϸ½Ú£¬ÒòΪ´ÓÓïÒåÉÏÀ´Ëµ£¬ËüÃDz¢²»ÖØÒª£¬ÉõÖÁÊÇÎ޹ؽôÒªµÄ¡£ËüÃÇ´¿´âÊÇ·ç¸ñºÍ¹ßÀýÎÊÌâ¡£ÆäÖÐÓÐЩϸ½ÚÓÐ×ÅËÆÊǶø·ÇµÄÀíÓÉ£¬ÆäËûһЩÉõÖÁÁ¬ËÆÊǶø·ÇµÄÀíÓÉҲûÓС£µ«ËùÓÐÕâЩϸ½Ú¶¼Êǵ±½ñ±àдµÄ Java ´úÂëÖÐÕæʵ´æÔÚµÄÏÖÏó¡£
ÕâÊÇʲôÓïÑÔ£¿
ÈÃÎÒÃÇÊ×ÏÈÀ´¿´Ò»¶Î´úÂ룬Æä×÷ÓÃÊǽ«»ªÊÏζÈת»»ÎªÉãÊ϶ȣ¬ÈçÇåµ¥ 1 Ëùʾ£º
Çåµ¥ 1. Ò»¶Î C ´úÂ룿
float F, C;
float min_tmp, max_tmp, x;
min_tmp = 0;
max_tmp = 300;
x = 20;
F = min_tmp;
while (F <= max_tmp) {
C = 5 * (F-32) / 9;
printf("%f\t%f\n", F, C);
F = F + x;
}
Çåµ¥ 1 ÖÐʹÓõÄÊÇʲôÓïÑÔ£¿ºÜÏÔÈ»ÊÇ C ÓïÑÔ —ÇëµÈһϣ¬ÈÃÎÒÃÇÀ´¿´¿´ÍêÕûµÄ³ÌÐò£¬ÈçÇåµ¥ 2 Ëùʾ£º
Çåµ¥ 2. Java ³ÌÐò
class Test {
public static void main(String argv[]) {
float F, C;
float min_tmp, max_tmp, x;
min_tmp = 0;
max_tmp = 300;
x = 20;
F = min_tmp;
while (F <= max_tmp) {
C = 5 * (F-32) / 9;
printf("%f\t%f\n", F, C);
F = F + x;
}
}
private static void printf(String format, Object... args) {
System.out.printf(format, args);
}
}
ÎÞÂÛÄúÊÇ·ñÏàÐÅ£¬Çåµ¥ 1 ºÍÇåµ¥ 2 ¶¼ÊÇʹÓà Java ÓïÑÔ±àдµÄ¡£ËüÃÇÖ»ÊÇÒÔ C ÓïÑÔ·½ÑÔ£¨ÀÏʵ˵
Ïà¹ØÎĵµ£º
JDO ¸ÅÊö
¡¡¡¡³¤¾ÃÒÔÀ´£¬Java Ó¦ÓóÌÐòºÍ³Ö¾ÃÊý¾Ý¹ÜÀíÖ®¼äµÄ¹ØϵһֱÊDz»ÈÝÒ×´¦ÀíµÄ¡£Ðí¶à³Ö¾ÃÐÔ»úÖÆÒÔ¹ØϵµÄ·½·¨¶ø²»ÊÇÃæÏò¶ÔÏó·½·¨´æ´¢Êý¾Ý¡£¼´£¬Êý¾Ý´æ´¢ÔÚÓÉ°üº¬×ֶεļǼ×é³ÉµÄ±íÖУ¬¶ø²»ÊǴ洢Ϊ×Ô°üº¬¶ÔÏó(ÕâЩ¶ÔÏóÓµÓÐÄÚ²¿Êý¾ÝºÍ¶ÔÆäËü¶ÔÏóµÄÒýÓ㬶øÆäËü¶ÔÏóÒ²ÓµÓÐÄÚ²¿Êý¾ÝºÍÒýÓÃ)¡£½«ÃæÏò¶ÔÏóµÄ±íʾת»»³ ......
¶ÔÓÚObjectÀà,ËüÌṩÁËÒ»¸ö×î×îÑÏÃܵÄʵÏÖ,ÄǾÍÊÇÖ»ÓÐÊÇͬһ¶ÔÏóʱ,equals·½·¨²Å·µ»Øtrue,Ò²¾ÍÊÇÈËÃdz£ËµµÄÒýÓñȽ϶ø²»ÊÇÖµ±È½Ï.Õâ¸öʵÏÖÑÏÃܵÃÒѾûÓÐʲôʵ¼ÊµÄÒâÒå, ËùÒÔÔÚ¾ßÌå×ÓÀà(Ïà¶ÔÓÚObjectÀ´Ëµ)ÖÐ,Èç¹ûÎÒÃÇÒª½øÐжÔÏóµÄÖµ±È½Ï,¾Í±ØÐëʵÏÖ×Ô¼ºµÄequals·½·¨
equals ·½·¨ÊÇ java.lang.Object ÀàµÄ·½·¨¡£
ÓÐÁ½ÖÖÓ ......
ÄÚÈÝ£º
¡¡¡¡Ê²Ã´ÊÇ·´±àÒ룿
¡¡¡¡·´»ã±àÒ»¸öÀàÎļþ
¡¡¡¡Ê¹Ó÷´±àÒëÆ÷
¡¡¡¡·´±àÒëºÍ¶Ô°²È«µÄÍþв
¡¡¡¡Õë·æÏà¶ÔµÄ´úÂëÄ£ºý´¦Àí
¡¡¡¡ÕâÒ»ÁìÓòµÄгÉÔ±
¡¡¡¡×ܽá
¡¡¡¡²Î¿¼×ÊÁÏ
¡¡¡¡¹ØÓÚ×÷Õß
¡¡¡¡ÆÀ¼Û±¾ÎÄ
¡¡¡¡Ïà¹ØÄÚÈÝ£º
¡¡¡¡ÈÃÄúµÄÈí¼þÔËÐУºÄ£ºý°²È«ÐÔ
¡¡¡¡Java ºÍ·Ö²¼Ê½Ä¿±êϵͳÉϵݲȫÐÔÑо¿
¡ ......
¸ö ÈË ¼ò Àú
ÐÕ Ãû£º
ÍõÖ¾¹ú
ÐÔ ±ð£º
ÄÐ
Äê Á䣺
23Ëê
ÁªÏµµç»°£º
13124799190
ר Òµ£º
¼ÆËã»ú¼¼Êõ
¹¤×÷ʱ¼ä£º
Ò»ÄêÒÔÉÏ
ѧ Àú£º
´óר
ÓÊ Ï䣺
andy478168@yeah.net
¡ï ÇóÖ°ÒâÏò
¹¤×÷ÐÔÖÊ ......
1.Duplicated Code
´úÂëÖظ´¼¸ºõÊÇ×î³£¼ûµÄÒìζÁË¡£ËûÒ²ÊÇRefactoringµÄÖ÷ҪĿ±êÖ®Ò»¡£´úÂëÖظ´ÍùÍùÀ´×ÔÓÚcopy-and-pasteµÄ±à³Ì·ç¸ñ¡£ÓëËûÏà¶ÔÓ¦OAOOÊÇÒ»¸öºÃϵͳµÄÖØÒª±êÖ¾¡£
2.Long method
ËüÊÇ´«Í³½á¹¹»¯µÄ“ÒŶ¾”¡£Ò»¸ö·½·¨Ó¦µ±¾ßÓÐ×ÔÎÒ¶ÀÁ¢µÄÒâͼ£¬²»Òª°Ñ¼¸¸öÒâͼ·ÅÔÚÒ»Æð¡£ ......