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

JavaÒì³£´¦Àí¼°Òì³£»úÖƽéÉÜ

Ò»£¬Ê²Ã´ÊÇÒì³£
      µ±³öÏÖ³ÌÐòÎÞ·¨¿ØÖƵÄÍⲿ»·¾³ÎÊÌ⣨Óû§ÌṩµÄÎļþ²»´æÔÚ£¬ÎļþÄÚÈÝË𻵣¬ÍøÂç²»¿ÉÓÃ...£©Ê±£¬JAVA¾Í»áÓÃÒì³£¶ÔÏóÀ´ÃèÊö¡£
JAVAÖÐÓÃ2ÖÖ·½·¨´¦ÀíÒì³££º
1.ÔÚ·¢ÉúÒì³£µÄµØ·½Ö±½Ó´¦Àí£»
2.½«Òì³£Å׸øµ÷ÓÃÕߣ¬Èõ÷ÓÃÕß´¦Àí¡£
JAVAÒì³£¿É·ÖΪ3ÖÖ£º
¡¡¡¡(1)¼ì²éÐÔÒì³£:java.lang.Exception.¼ì²éÐÔÒì³£------³ÌÐòÕýÈ·£¬µ«ÒòΪÍâÔڵĻ·¾³Ìõ¼þ²»Âú×ãÒý·¢¡£ÀýÈ磺Óû§´íÎó¼°I/OÎÊÌâ----³ÌÐòÊÔͼ´ò¿ªÒ»¸ö²¢²»´æÔÚµÄÔ¶³ÌSocket¶Ë¿Ú¡£Õâ²»ÊdzÌÐò±¾ÉíµÄÂß¼­´íÎ󣬶øºÜ¿ÉÄÜÊÇÔ¶³Ì»úÆ÷Ãû×Ö´íÎó(Óû§Æ´Ð´´íÎó)¡£JAVA±àÒëÆ÷Ç¿ÖÆÒªÇó´¦ÀíÕâÀàÒì³££¬Èç¹û²»²¶»ñÕâÀàÒì³££¬³ÌÐò½«²»Äܱ»±àÒë¡£
¡¡¡¡(2)ÔËÐÐÆÚÒì³£:java.lang.RuntimeException.ÔËÐÐÆÚÒì³£------ÕâÒâζ×ųÌÐò´æÔÚbug£¬ÈçÊý×éÔ½½ç£¬0±»³ý£¬Èë²Î²»Âú×ã¹æ·¶.....ÕâÀàÒì³£ÐèÒª¸ü¸Ä³ÌÐòÀ´±ÜÃ⣬JAVA±àÒëÆ÷Ç¿ÖÆÒªÇó´¦ÀíÕâÀàÒì³£¡£
¡¡   (3)´íÎó:java.lang.Error.´íÎó------Ò»°ãºÜÉÙ¼û£¬Ò²ºÜÄÑͨ¹ý³ÌÐò½â¾ö¡£Ëü¿ÉÄÜÔ´ÓÚ³ÌÐòµÄbug£¬µ«Ò»°ã¸ü¿ÉÄÜÔ´ÓÚ»·¾³ÎÊÌ⣬ÈçÄÚ´æºÄ¾¡¡£´íÎóÔÚ³ÌÐòÖÐÎÞÐë´¦Àí£¬¶øÓÉÔËÐл·¾³´¦Àí¡£
      ¶¥²ãÊÇjava.lang.ThrowableÀ࣬¼ì²éÐÔÒì³££¬ÔËÐÐÆÚÒì³££¬´íÎó¶¼ÊÇÕâ¸öÀàµÄ×ÓËïÀà¡£java.lang.ExceptionºÍjava.lang.Error¼Ì³Ð×Ôjava.lang.Throwable,¶øjava.lang.RuntimeException¼Ì³Ð×Ôjava.lang.Exception
¶þ£¬ÈçºÎ´¦ÀíÒì³££¿
1.try...catch ¡£³ÌÐòÔËÐвúÉúÒ쳣ʱ£¬½«´ÓÒì³£·¢ÉúµãÖжϳÌÐò²¢ÏòÍâÅ׳öÒì³£ÐÅÏ¢¡£
int x = (int)(Math.random()*5);
int y = (int)(Math.random()*10);
int[] z =new int[5];
try
{
    System.out.println("y/x="+(y/x));
    System.out.println("y="+y+"z[y]="+z[y]);
}
catch (ArithmeticException exc1)
{
    System.out.println("ËãÊõÔËËãÒì³£:"+exc1.getMessage());
}
catch (ArrayIndexOutOfBoundsException exc2)
{
    System.out.println("Êý¾ÝÔ½½çÒì³£:"+exc2.getMessage());
}
˵Ã÷:ArithmeticExceptionºÍArrayIndexOutOfBoundsException¶¼ÊôÔËÐÐÆÚÒì³££ºjava.lang.RuntimeException£¬Èç¹û²»ÓÃtry...catch²¶»ñ£¬³ÌÐòÒ²ÊÇ¿Éͨ¹ý±àÒëµÄ£¬µ«Èç¹ûÊôÓÚ¼ì²éÐÔÒì³££ºjava.lang.Exception£¬±ØÐë¶øÇÒÒ»¶¨ÒªÓÃtry...catch...¶ÔÆä½øÐд¦Àí¡£
2.finally¡£Èç¹û°Ñfinally¿éÖÃtr


Ïà¹ØÎĵµ£º

Java²Ù×÷ÎļþÒ»£¨pdf£©

Ò»¡¢Ð´pdf
ÐèÒª°ü£ºiText-2.1.0.jar
ÖÐÎÄ´¦Àí£ºiTextAsian.jar
1¡¢HelloWorldÀý×Ó
package com.my.file.pdf;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class HelloWorld ......

JavaÖеÄÉÖÆÓëdz¸´ÖÆ

1£®Ç³¸´ÖÆÓëÉÖƸÅÄî
¢Ådz¸´ÖÆ£¨Ç³¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔ­À´µÄ¶ÔÏóÏàͬµÄÖµ£¬¶øËùÓеĶÔÆäËû¶ÔÏóµÄÒýÓÃÈÔȻָÏòÔ­À´µÄ¶ÔÏó¡£»»ÑÔÖ®£¬Ç³¸´Öƽö½ö¸´ÖÆËù¿¼ÂǵĶÔÏ󣬶ø²»¸´ÖÆËüËùÒýÓõĶÔÏó¡£
 
¢ÆÉÖÆ£¨Éî¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔ­À´µÄ¶ÔÏóÏàͬµÄÖµ£¬³ýÈ¥ÄÇЩÒýÓÃÆäËû¶ÔÏóµÄ±äÁ¿¡ ......

CµÄenum struct ÒÔ¼° JavaµÄenum

 ÔÚcÖÐenumµÄʹÓúÍstructºÜÏñ
enum name{
a,b,c
};

 
struct name{
int a;
int b;
char c;
};

 
or
 
typedef struct{
int a;
int b;
char c;
}Name;

ʹÓõÄʱºò¶¼ÒªÏÈÉùÃ÷±äÁ¿
 
enum name n1,n2,n3;
n1=a;
n2=b;
n3=enum name(3-1);
struct name sn1,sn2;
s ......

JAVA×Ô¶¯×°ÏäÓë²ðÏä

×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÂʵÉÏÊDZàÒëÆ÷À´°ïÄúµÄ棬±àÒëÆ÷ÔÚ±àÒëʱÆÚÒÀÄúËù±àдµÄÓï·¨£¬¾ö¶¨ÊÇ·ñ½øÐÐ×°Ïä»ò²ðÏ䶯×÷¡£ÀýÈ磺
Integer i = 100.Ï൱ÓÚ±àÒëÆ÷×Ô¶¯ÎªÄú×÷ÒÔϵÄÓï·¨±àÒ룺
Integer i = new Integer(100).ËùÒÔ×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÇËùνµÄ“±àÒëÆ÷ÃÛÌÇ”(Compiler Sugar)£¬ËäȻʹÓÃÕâ¸ö¹¦Äܷܺ½±ã£¬µ ......

ÔÚJavaÖжÔExcel²Ù×÷

´´½¨Ò»¸öÎļþtemp£¬Í¬Ê±ÔÚtemp Ŀ¼Ï´´½¨Ò»¸öoutpath.xls
д²Ù×÷
 
package com;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.DateTime;
import jxl.write.Label;
import jxl.write.Number ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ