Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Effective Java¶ÁÊé±Ê¼Ç

package chape8;
import java.math.BigDecimal;
/**
* 8-48
* Èç¹ûÏëÒªÖªµÀ¾«È·µÄ´ð°¸£¬¾ÍÒª±ÜÃâʹÓÃdoubleºÍfloat
¶ÔÓÚ½ðÈÚÐÐÒµÀ´Ëµ£¬¶ÔÊý¾ÝµÄÑÏÕûÐÔÒªÇóÊǺܸߵģ¬²»ÈÝ°ëµãÂí»¢£¬
ÄÇ´ó¼Ò¶¼ÖªµÀÔÙÎÒÃǵÄJavaÓïÑÔÀïÃæÓÐÁ½¸ö¸¡µãÊýÀàÐ͵ıäÁ¿floatºÍdouble£¬
¿ÉÄÜ´ó¼Ò»áÈÏΪËûÃǵľ«¶È¶ÔÓÚ½ðÈÚÐÐÒµÕâÑù¶ÔÊý×ÖÃô¸ÐµÄÐÐÒµÀ´Ëµ£¬ÒѾ­¹»ÓÃÁË£¬
µ«ÊÇÔÚ¿ª·¢µ±ÖУ¬ÎÒÃÇÒª¾¡Á¿ÉÙʹÓÃdoubleºÍfloat£¬ÒòΪÈÃËûÃǾ«È·µÄ±í´ï0.1ÊDz»¿ÉÄܵġ£
ÄÇÎÒÃÇÈçºÎ½â¾öÕâ¸öÎÊÌâÄØ£¬
´ð°¸ÊÇʹÓÃBigDecimal,int»òÕßlong½øÐлõ±Ò¼ÆËã¡£
ÔÚÕâÀï¶Ô´ó¼ÒµÄÖÒ¸æÊÇ£º
floatºÍdouble ÀàÐÍÓÈÆä²»ÊʺÏÓÃÓÚ»õ±Ò¼ÆË㣻ÒòΪÈÃÒ»¸öfloat»òÕßdouble
¾«È·µØ±íʾ0.1»òÕß10µÄÈκÎÆäËû¸ºÊý´Î·½Öµ£¬¶¼ÊDz»¿ÉÄܵģ»
* @author lee
*
*/
public class Chape48 {
/**
* @param args
*/
public static void main(String[] args) {
/**
* À´¿´Ò»¸öÀý×Ó
* Äã¿Ú´üÀïÓÐ1ÃÀÔª£¨100ÃÀ·Ö£©£¬Äã´òËãÂòÌÇ£¬Ìǵļ۸ñΪ10ÃÀ·Ö20ÃÀ·Ö
* 30ÃÀ·ÖµÈµÈ Ò»Ö±µ½1ÃÀ·Ö Äã´òËã´Ó10ÃÀ·ÖµÄ¿ªÊ¼Âò£¬Ã¿ÖÖ¼Û¸ñÖ»ÂòÒ»¸ö
* ÄÇÄãÄÜÂò¼¸¸öÌÇÄØ£¿ÄÜÕһضàÉÙÄØ£¿
*/
/* double sum = 1;
int count = 0 ;
for(double x = .10;x<sum;x+=.10)
{
sum-=x;
count++;
}
System.out.println(sum);
System.out.println(count);*/
/**
* Êä³ö½á¹ûÊÇ
* 0.3999999999999999ºÍ3
* ÎÒÃÇÓÃÊÖËãһϠ100-10-20-30=40
* ÄǾÍÊÇ˵ÎÒÃÇ»¹¿ÉÒÔÂòÒ»¸ö.40µÄÌÇ ÄÇô³ÌÐòÄÇÀï´íÁË£¿
* ´íÎó¾ÍÔÚÓÚÎÒÃÇÓÃÁËdouble
* ½â¾ö°ì·¨¾ÍÊÇÓÃBigDecimal »òÕßint »òÕßlong ½øÐлõ±ÒµÄ¼ÆËã
*/
BigDecimal sum1 = new BigDecimal("1");
BigDecimal price = new BigDecimal(".10");
int count1 = 0 ;
for(BigDecimal b = price;sum1.compareTo(b) >=0 ;b=b.add(price))
{
sum1 = sum1.subtract(b);
count1++;
}
System.out.println(sum1);
System.out.println(count1);
/**
* Êä³ö½á¹û0.00ºÍ4 ÕâÑù¾ÍÕýÈ·ÁË
* ¹ØÓÚBigDecimalµÄ·½·¨ÎÒÃÇÏÂÈ¥ÔÙ×Ðϸ¿´¿´£»
* ÕâÀïҪ˵µÄÊÇBigDecimalÊÇÒýÓÃÊý¾ÝÀàÐÍ
*/
/**
* ×ܶøÑÔÖ®£º ¶ÔÓÚÈκÎÒª¾«È·´ð°¸µÄ¼ÆËãÈÎÎñ£¬Çë²»ÒªÓÃdoubleºÍfloat£¬Èç¹ûÄãÏë
* ¼ÆËãÊ®½øÖÆСÊýµã£¬²¢ÇÒ²»½éÒâ·Ç»ù±¾ÀàÐÍ´øÀ´µÄ²»±ã£¬ÄǾÍÓÃBigDecimal£»Ê¹ÓÃ
* BigDecimal»¹Óиö¶îÍâµÄºÃ´¦¾ÍÊÇËûÔÊÐíÄãÍêÈ«¿ØÖÆÉáÈ룬ÿµ±Ò»¸ö²Ù×÷Éæ¼°


Ïà¹ØÎĵµ£º

java elÅäÖúÍʹÓÃ


Ê×ÏÈÈ·¶¨ÓõÄServlet / JSPµÄ°æ±¾¡£
²é¿´web.xmlµÄ¿ªÍ·²¿·Ö£¬Èç¹ûÓÐÒÔÏÂÄÚÈÝ£¬±íʾÊÇServlet 2.4 / JSP 2.0¡£
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.s ......

java¼¯ºÏÀà

 ArrayList ºÍVectorÊDzÉÓÃÊý×鷽ʽ´æ´¢Êý¾Ý£¬´ËÊý×éÔªËØÊý´óÓÚʵ¼Ê´æ´¢µÄÊý¾ÝÒÔ±ãÔö¼ÓºÍ²åÈëÔªËØ£¬¶¼ÔÊÐíÖ±½ÓÐòºÅË÷ÒýÔªËØ£¬µ«ÊDzåÈëÊý¾ÝÒªÉè¼Æµ½Êý×éÔªËØÒƶ¯µÈÄÚ´æ²Ù×÷£¬ËùÒÔË÷ÒýÊý¾Ý¿ì²åÈëÊý¾ÝÂý£¬VectorÓÉÓÚʹÓÃÁËsynchronized·½·¨£¨Ḭ̈߳²È«£©ËùÒÔÐÔÄÜÉϱÈArrayListÒª²î£¬LinkedListʹÓÃË«ÏòÁ´±íʵÏÖ´æ´¢£¬°´Ðòº ......

JavaÖеÄIOÁ÷֪ʶ×ܽᣨת£©

×ܽáÒ»£º
Java IOµÄÒ»°ãʹÓÃÔ­Ôò£º
Ò»¡¢°´Êý¾ÝÀ´Ô´£¨È¥Ïò£©·ÖÀࣺ
1¡¢ÊÇÎļþ£º FileInputStream, FileOutputStream, FileReader, FileWriter
2¡¢ÊÇbyte[]£ºByteArrayInputStream, ByteArrayOutputStream
3¡¢ÊÇChar[]: CharArrayReader, CharArrayWriter
4¡¢ÊÇString: StringBufferInputStream, StringReader, StringW ......

JAVA AJAX½Ì³ÌµÚËÄÕ—AJAXºÍMVCµÄ¼òµ¥½áºÏ

 ÕâÀïÎÒÃÇÔÙÀí½âÁËAJAXºó£¬¿ªÊ¼À´ÓÃʵÀý¸ÐÊÜAJAXµÄÁ¦Á¿¡£
½ñÌìÎÒ×îºóҪʵÏÖµÄЧ¹û£¬µ±Êó±ê·Åµ½Í¼Æ¬ÉÏʱ»á¸ù¾Ý£¬»á°ÑÊý¾Ý¿â¿âÀïµÄÊý¾Ý¶Á³ö£¬Í¨¹ýÏÔʾ¿òÏÔʾ³öÀ´¡£Õâ¸öÔںܶàÍøÉÏÉ̵궼ÓÐÓõ½ÕâÀïЧ¹û£¬ÎÒÃÇÕâÀïÓÃAJAXÀ´ÊµÏÖÕâ¸öЧ¹û¡£Õâ¸öʵÀýÀï½áºÏÁËMySql¡¢Servlet»¹ÓÐJs£¬ÀíÂÛÐÔºÜÉÙ£¬µ«Í¨¹ýʵ¼ùÀ´¸ÐÊÜÀíÂÛ֪ʶ¡£
......

java¶ÁÈ¡txtÎı¾

  public List createArrayList(String FilePath,String FileName){
     List  list =new ArrayList();
  FileName=FilePath+"\\"+FileName;
  
  File file=new File(FileName);
  String encoding="GBK";//·ÀÖ¹ÂÒÂë Õâ±àÂëÐèÒª¸ù¾Ý×Ô¼ºµÄ²Ù ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ