Ò»¸öÈÃ98%java³ÌÐòÔ±·¸ÄѵÄÎÊÌâµÄ˼¿¼
Ô´´úÂ룺
public class Parent
{
protected void test() {}
public Parent()
{
this.test();
}
public static void main(String[] args)
{
new Child();
}
}
class Child extends Parent
{
private int instanceValue = 1£»
public void test()
{
System.out.println("instance value is: " + instanceValue);
}
}
--------------------------------------------
´Ë³ÌÐòµÄÊä³ö½á¹ûΪinstance value is:0£¬¿ÉÄܺܶàÈË£¨°üÀ¨ºÜ¶àÀϳÌÐòÔ±£©¶¼»áÏ뵱ȻµÃÒÔΪÊä³ö½á¹ûΪ1£¬»òÕß²»»áÓÐÊä³ö£¬»òÕßÈÏΪÕâ¸ö³ÌÐò±¾Éí¾ÍÊÇ´íµÄ£¨ÎÒµÄÀÏʦ¾ÍÊÇÕâôÈÏΪµÄ£¬ºÇºÇ~£©
¿´Á˺ܶàÓйØÕâ¸öÎÊÌâµÄÌÖÂÛ£¬ÏÖÔÚÌá³öÒ»µãÎҵļû½â£º
·ÖÎö£ºÕâ¸öÎÊÌâÊ×ÏÈÉæ¼°µÄ֪ʶÊÇÀà¼ÓÔØ·ÖΪÈý¸ö¹ý³Ì£º×°ÔØ¡¢Á´½Ó¡¢³õʼ»¯£¬ÓйØÕâ¸ö֪ʶÎÒÔÚ֮ǰµÄÌû×Ó“Àà¼ÓÔØ·ÖΪÈý¸ö¹ý³Ì£º×°ÔØ¡¢Á´½Ó¡¢³õʼ»¯”ÖÐÓÐרÃÅÌáµ½¹ý£¬¶øÕæÕýÁ˽âÕâ¸ö֪ʶµÄÈ˲¢²»¶à£¬ËùÒÔ²ÅÓÐÁËÈç±êÌâËù˵µÄ½á¹û~
OK£¬ÏÖÔÚÎÒÃÇÀ´¿ªÊ¼Ò»²½²½·ÖÎö£ºÊ×ÏȼÓÔØclassÎļþ£¬¶ÔÀàÖеıäÁ¿½øÐÐÄÚ´æ·ÖÅ䣨ÉùÃ÷£©£¬´ËʱinstanceÊÇʵÀý±äÁ¿£¬¼ÓÔصÄʱºò²¢²»»á¶ÔÆä½øÐÐÕæÕýµÄ³õʼ»¯£¨¼´²»»á°Ñ1¸³¸øËü£¬ËüÖ»»áµÃµ½ÏµÍ³¸øËüµÄĬÈÏÖµ0£¬ÕâÊÇÎÊÌâµÄ¹Ø¼ü£©¡£
½ÓÏÂÀ´¾ÍÒªÖ´ÐÐmain·½·¨ÌåÁË£¬ok£¬ËüÀïÃæÖ»ÓÐÒ»ÌõÓï¾ä£¬newÒ»¸ö×ÓÀà¶ÔÏ󣬵÷ÓÃ×ÓÀàĬÈϹ¹ÔìÆ÷µÄʱºòÒªÏȵ÷Óø¸ÀàµÄÎ޲ι¹ÔìÆ÷£¬¸¸À๹ÔìÆ÷Õâʱ»áµ÷Óø¸ÀàµÄtest·½·¨£¬¸ù¾Ý¶à̬ÔÀí£¬¸Ãtest·½·¨½«»á±»×ÓÀàµÄtest¸²¸Ç£¬×ÓÀà·½·¨½«»á´òÓ¡Ò»ÌõÓï¾ä£¬¶ø´Ëʱinstance±äÁ¿²¢Î´±»³õʼ»¯£¬¹Ê´òÓ¡µÄ½á¹ûΪ0.ÕâÀïµÄthis.test£¨£©·½·¨µ÷ÓÿÉÄܲ»ÊǺܺÃÀí½â£¬ÒòΪËüÒѾÓÃthis±íÃ÷µ÷Óø¸Àà·½·¨£¬´ËʱËüÊDz»ÖªµÀ×ÓÀàÒѾ¸²¸ÇÁ˸¸ÀàµÄÕâ¸ö·½·¨£¬¹ØÓÚÕâÒ»µã£¬Ä¿Ç°»¹ÕÒ²»µ½½âÊ͵ķ½·¨£¬¹ÃÇÒ°ÑËüÀí½âΪ¶à̬»úÖÆ°É¡£
ºÃÁË£¬ÏÖÔÚÎÒÃǰѳÌÐòÉÔ΢¸Ä¶¯Ò»Ï£¬¾ÍÊÇ°Ñprivate int instanceValue = 1£»¸ÄΪprivate static int instanceValue = 1£»´ËʱÊä³öµÄ½á¹û¾ÍΪ1ÁË£¬ÒòÎ
Ïà¹ØÎĵµ£º
¶ÔÓÚ½«ÒªÊ¹ÓõÄJSP¹æ·¶µÄÒ»¸öÌص㣬¾ÍÊÇJSP±í´ïʽÓïÑÔ¡£Ôںܴó³Ì¶ÈÉÏ£¬ËüÊÇÓÐÒâ¼ò»¯µÄ£¬²¢¶ÀÁ¢ÓÚJSP¡£
ÔÚJSPµÄÔçÆÚ°æ±¾ÖУ¬Java´úÂëÒԽű¾µÄÐÎʽǶÈëµ½JSPÒ³ÃæÖУ¬ÀýÈ磺
<%
MyBean bean = new MyBean();
String name = bean.getName();
out.println(name);
%>
Õâ¸ö½Å±¾´úÂëн¨ÁËÒ»¸öÃûΪMyBeanµÄʵÀý£¬»ñµÃË ......
À´×Ô:http://www.cnblogs.com/shiyangxt/archive/2008/07/30/1256813.html
»·¾³£ºMyEclipse
Êý¾Ý¿â£ºmysql
Ê×ÏÈн¨JavaÏîÄ¿£¬È»ºóн¨Á½¸öÀ࣬һ¸öÊý¾Ý¿âÁ¬½Ó³ØÀ࣬һ¸ö²âÊÔÀà¡£
·Ö±ðÃüÃûConnectionPool£¬ConnectionPoolTest¡£
È»ºóн¨Ò»¸öÅäÖÃÎļþ£¬ÃüÃû£ºdbpool.properties¡£
&n ......
Ò»¡¢²»±äģʽ£º
Ò»¸ö×Ö·û´®¶ÔÏó´´½¨ºóËüµÄÖµ²»Äܸı䡣
String str1="hello";//´´½¨Ò»¸ö¶ÔÏóhello£¬²»»á±ä£»
System.out.println(str1);
str1+=" world!";//Á½¸ö×Ö·û´®¶ÔÏóÕ³Õ³£¬ÏµÍ³Æäʵ´´½¨ÁËÒ»¸öеĶÔÏ󣬰ÑStr1µÄÖ¸Ïò¸ÄÁË£¬Ö¸ÏòеĶÔÏó£»hello¾Í & ......
ÔÚʵÏÖsingletonģʽʱ£¬ÎÒÃÇÓÐÒÔϼ¸ÖÖ·½·¨¡£ 1. public static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯Êý¡£ public class Singleton{
public static final Singleton INSTANCE = new Singleton();
......
Ìù×ÓÖв¿·ÖÔ´´úÂëÕª×ÔcsdnµÄһƪÌû×Ó£¬ ²Î¿¼ÁËËûÃǵÄÀí½â£¬ËµËµ×Ô¼ºµÄһЩ¼û½â£º
//Ô´´úÂ룺
class A {
public String show(D obj){
return ("A and D");
......