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

Java×Ô¶¨ÒåÒì³£Àà

×Ô¶¨ÒåÒì³£ : ²½Öè: ­
Ò»:´´½¨Ò»¸öÀà¼Ì³ÐÓÚThrowable»òÆä×ÓÀà; ­
¶þ:Ìí¼Ó¹¹Ôì·½·¨; ­
Èý:ÔÚÒ»¸ö·½·¨ÖÐʹÓÃthrowÅ׳öÒì³£ ­
ËÄ:ÔÚÁíÒ»¸ö·½·¨Öв¶»ñ²¢´¦ÀíÒì³£ ­
ʾÀý:
Ò»¡¢ ¼Ì³ÐThrowable Àà
public class MySecondException extends Throwable {
public MySecondException() {
super();
}
public MySecondException(String msg) {
super(msg);
}
public MySecondException(String msg, Throwable cause) {
super(msg, cause);
}
public MySecondException(Throwable cause) {
super(cause);
}
}

¶þ¡¢¼Ì³ÐExceptionÀà
public class MyFirstException extends Exception {
public MyFirstException() {
super();
}
public MyFirstException(String msg) {
super(msg);
}
public MyFirstException(String msg, Throwable cause) {
super(msg, cause);
}
public MyFirstException(Throwable cause) {
super(cause);
}
//×Ô¶¨ÒåÒì³£ÀàµÄÖ÷Òª×÷ÓÃÊÇÇø·ÖÒì³£·¢ÉúµÄλÖ㬵±Óû§Óöµ½Ò쳣ʱ£¬
//¸ù¾ÝÒì³£Ãû¾Í¿ÉÒÔÖªµÀÄÄÀïÓÐÒì³££¬¸ù¾ÝÒì³£ÌáʾÐÅÏ¢½øÐÐÐ޸ġ£
}

Èý¡¢²âÊÔ
/**
* ×Ô¶¨ÒåÒì³£ÀàµÄʹÓÃ
* @author new
*
*/
public class TestMyException {
public static void firstException() throws MyFirstException{
throw new MyFirstException("\"firstException()\" method occurs an exception!");
}

public static void secondException() throws MySecondException{
throw new MySecondException("\"secondException()\" method occurs an exception!");
}
public static void main(String[] args) {
try {
TestMyException.firstException();
TestMyException.secondException();
} catch (MyFirstException e1){
System.out.println("Exception: " + e1.getMessage());
e1.printStackTrace();
} catch (MySecondException e2){
System.out.println("Exception: " + e2.getMessage());
e2.printStackTrace();
}
//µ±Ò»¸ötry¿éºóÃæ¸ú×Ŷà¸öcatch¿éʱ£¬Èç¹û·¢ÉúµÄÒ쳣ƥÅäµÚÒ»¸öcatch¿éµÄ²ÎÊý£¬±ã½«Òì³£´¦ÀíȨÀû½»¸øµÚÒ»¸öcatch¿é¡£
//Èç¹û·¢ÉúµÄÒì³£ÓëµÚÒ»¸öcatch¿é²»Æ¥Å䣬±ã¿´


Ïà¹ØÎĵµ£º

javaÖбéÀúÒ»¸öMap

Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
......

Java ´¦ÀíÒì³££¨³£¼ûÒì³£±í£©

Òì³£ÁÐ±í£º
1. java.lang.nullpointerexception 
2. Java.lang.classnotfoundexception
3. Java.lang.arithmeticexception
4. Java.lang.arrayindexoutofboundsexception
5. Java.lang.illegalargumentexception
6. java.lang.illegalaccessexception
1. java.lang.nullpoi ......

JavaÏß³Ìͬ²½ £¨synchronized wait notify£©

×¢£ºwait notify ¶¼ÊÇObjectµÄ·½·¨
 
ͬ²½£¨×èÈû£© £ºÊÇÒ»ÖÖ·ÀÖ¹¶Ô¹²Ïí×ÊÔ´·ÃÎʵ¼ÖµÄÊý¾Ý²»Ò»ÖµÄÒ»ÖÖģʽ¡£
ÏêϸÇë²Î¿´²Ù×÷ϵͳ¡£
ÔÚJavaÖУ¬ÓÉÓÚ¶Ô¶àÏ̵߳ÄÖ§³Ö£¬¶Ôͬ²½µÄ¿ØÖÆÖ÷Ҫͨ¹ýÒÔϼ¸¸ö·½·¨£¬synchronized£¬ºÍwait(),notify()ºÍnotifyAll(),ÏÂÃæ½øÐÐÒ»Ò»µÄ½²½â£º
A¹Ø¼ü×Ösynchronized
ÿ¸öjava¶Ô ......

JAVA IO »ù±¾Ð¡½á

javaµÄIOÊÇ»ùÓÚÁ÷£¨stream£©¸ÅÄîµÄ£¬Ê²Ã´ÊÇÁ÷ÄØ£¬×÷Ϊ³õѧÕߣ¬ÎÒÊÇÕâÑùÀí½âµÄ£¬ÔÚ¸÷¸öÓ¦ÓÃÖ®¼ä´«Ë͵ÄÊÇBITS£¬ÕâЩBIT¿ÉÒѱ»ÈÏΪÊÇÁ÷Ì壬¿ÉÒÔ¾ÍÈÏΪÊÇË®Á÷£¬ÄÇôÓÃÀ´ÔÚ¸÷¸öˮԴ֮¼ä×ªÒÆË®µÄ¹¤¾ßÓ¦¸ÃÑ¡ÔñÊ²Ã´ÄØ£¿Ò»°ãÇé¿öÏ£¬Ë®¹ÜÊÇ¿ÉÒԵģ¬ËùÒÔÊý¾ÝÎÒ½«Êý¾ÝÔ´±È×÷ˮԴ£¬½«Á÷¶ÔÏó±È×÷Ë®¹Ü£¬ÕâÑù¾ÍÓÐÁ˶ÔÁ÷µÄµÚÒ»²½ÈÏʶ£¬ËüÔÙÒ ......

Java¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨

Java¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
Java¶ÁÈ¡propertiesÎļþ
ʹÓÃJ2SE API¶ÁÈ¡PropertiesÎļþµÄÁùÖÖ·½·¨
1¡£Ê¹ÓÃjava.util.PropertiesÀàµÄload()·½·¨
ʾÀý£º InputStream in = lnew BufferedInputStream(new FileInputStream(name));
Properties p = new Properties();
p.load(in);
2¡£Ê¹ÓÃjava.util.ResourceBundleÀ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ