Java»ñµÃÖ¸¶¨ClassLoaderËù¼ÓÔØµÄÀàÁбí
Ò»Ö±ÏëʵÏÖÏñDriverManagerÄÇÑùµÄgetConnection·½·¨£¬Í¨¹ý´Ë·½·¨¾Í¿ÉÒÔ»ñµÃÁ¬½Ó£¬¶øÇÒ»¹²»ÓÃÖ¸¶¨Driver£¬µ«Ç°ÌáÊÇDriverÒѾͨ¹ýClass.forName()»ònew Driver()½øÐÐÁ˼ÓÔØ¡£½ñÌìÖÕÓÚµÃÒÔʵÏÖ¡£
package quiz;
import java.lang.reflect.Field;
public class ClassLoaderDriver {
/**
* @param args
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalAccessException
* @throws IllegalArgumentException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
Field field = ClassLoader.class.getDeclaredField("classes");
field.setAccessible(true);//ÉèÖøóÉÔ±±äÁ¿Îª¿É·ÃÎÊ
System.out.println(field.get(ClassLoader.getSystemClassLoader()));
}
}
ÕâÑùÒ»À´£¬ÎÒÃǾͿÉÒÔʵÏÖºÍDriverManagerÀàËÆµÄ¹¦ÄÜÁË¡£
Ïà¹ØÎĵµ£º
ºÇºÇ£¡»¹ÊÇÏȸø´ó¼Ò³ö¸öÌâ°É£¡
public class PreferenceTest {
public int testVar = 0;
/**
* create data: 2009-12-30</br> Just for me to test preference.
*
* @author XiangJie
* @param args
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stu ......
JAVAÖ®IOÁ÷(³¬ÏêϸµÄJava.io°üµÄ½éÉÜ!)
Ò».InputºÍOutput
1.stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£
ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ ......
ÔÚJavaÖÐÓÐÁ½ÖÖ²»Í¬µÄ¶Ô±äÁ¿¸³Öµ·½Ê½£¬Ò»ÖÖÊÇÖ±½Ó½«Ò»¸öÖµ¸³¸ø±äÁ¿¡£ÀýÈ磺
int a = 1;
String s = "abc";
Integer in = 125;
ÁíÍâÒ»ÖÖÊÇ´´½¨Ò»¸ö¶ÔÏ󣬲¢½«Æä¸³¸øÒ»¸ö±äÁ¿¡£ÀýÈ磺
String s = new String("abc")
Integer in = new Integer(125);
Á½ÖÖ·½Ê½µÄ²»Í¬Ö®´¦ÔÚÓÚ£º
µÚÒ»ÖÖ·½Ê½±äÁ¿µÄÖµ´æ´¢ÔÚ¶ÑÕ»ÖУ¬µ±ÏÂÒ» ......