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

JAVA¹æ·¶Ñ§Ï°——static³ÉÔ±³õʼ»¯

class Super { static int taxi = 1729; }
class Sub extends Super {
static { System.out.print("Sub "); }
}
class Test {
public static void main(String[] args) {
System.out.println(Sub.taxi);
}
}
Êä³ö£º1729
֪ʶҪµã£º
A reference to a class field causes initialization of only the class or interface
that actually declares it, even though it might be referred to through the name of a
subclass, a subinterface, or a class that implements an interface.
Ò²¾ÍÊÇ˵ֻÓÐʹÓøÃÀà»òÕß½Ó¿ÚÖ±½Ó¶¨ÒåµÄÀà±äÁ¿£¬²Å»á¼¤·¢¸ÃÀàµÄ³õʼ»¯£»Èç¹ûʹÓõÄÊÇÆ丸ÀඨÒåµÄÀà±äÁ¿£¬Ôò×ÓÀ಻»á±»³õʼ»¯
interface I {
int i = 1, ii = Test.out("ii", 2);
}
interface J extends I {
int j = Test.out("j", 3), jj = Test.out("jj", 4);
}
interface K extends J {
int k = Test.out("k", 5);
}
class Test {
public static void main(String[] args) {
System.out.println(J.i);
System.out.println(K.j);
}
static int out(String s, int i) {
System.out.println(s + "=" + i);
return i;
}
}
Êä³ö£º
1
j=3
jj=4
3
 ÖªÊ¶Òªµã£º
Initialization of an interface does not, of itself, cause initialization of any of its
superinterfaces.
The reference to J.i is to a field that is a compile-time constant; therefore, it
does not cause I to be initialized. The reference to K.j is a reference to a field
actually declared in interface J that is not a compile-time constant; this causes initialization
of the fields of interface J, but not those of its superinterface I, nor
those of interface K. Despite the fact that the name K is used to refer to field j of
interface J, interface K is not initialized.


Ïà¹ØÎĵµ£º

javaÐÔÄܵÄÓÅ»¯(Ò»)

 
ÎÒ¶ÔÎÊÌâµÄÀí½â£ºÃæÊÔÖеÄÒ»¸öÎÊÌ⣬¾ÓÈ»ÏëÁË°ëÌìûÓÐʲôͷÐ÷£¬ÎÒÏ뻹ÊÇûÓÐ˼¿¼£¬Ã»ÓлýÀÛ¹ý¡£ÆäʵÍêÈ«¿ÉÒÔ˵ÉÏһЩСϸ½Ú£¬±ÈÈçÓÃStringBuffer´úÌæString£¬ÓÃHashMap´úÌæHashtable, ³Ë·¨²Ù×÷ÓÃλÒÆ£¬¾¡Á¿¸´ÓÃÒÑÓеľ­¹ý¼ìÑéµÄ¸ßЧ´úÂëµÈµÈ¡£
    ÏÂÃæµÄÎÄÕÂתÔØ×Ô±ðµÄÍøÕ¾£¬Ð´µÃºÜרҵ£¬Öܵ½£¬ ......

Javaµ÷ÓÃSQL ServerµÄ´æ´¢¹ý³ÌÏê½â

1ʹÓò»´ø²ÎÊýµÄ´æ´¢¹ý³Ì
¡¡¡¡Ê¹Óà JDBC Çý¶¯³ÌÐòµ÷Óò»´ø²ÎÊýµÄ´æ´¢¹ý³Ìʱ£¬±ØÐëʹÓà call SQL תÒåÐòÁС£²»´ø²ÎÊýµÄ call תÒåÐòÁеÄÓï·¨ÈçÏÂËùʾ£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º
{call procedure-name}
¡¡¡¡×÷ΪʵÀý£¬ÔÚ SQL Server 2005 AdventureWorks ʾÀýÊý¾Ý¿âÖд´½¨ÒÔÏ´洢¹ý³Ì£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º ......

Java AnnotationʹÓôóÈ« (ZT)


Ò»¡¢Annotation¾¿¾¹ÊÇʲô£¿
    Annotation ÌṩÁËÒ»ÌõÓë³ÌÐòÔªËعØÁªÈκÎÐÅÏ¢»òÕßÈκÎÔªÊý¾Ý£¨metadata£©µÄ;¾¶¡£´ÓijЩ·½Ãæ¿´£¬annotation¾ÍÏñÐÞÊηûÒ»Ñù±»Ê¹Ó㬲¢Ó¦ÓÃÓÚ°ü¡¢ÀàÐÍ¡¢¹¹Ôì·½·¨¡¢·½·¨¡¢³ÉÔ±±äÁ¿¡¢²ÎÊý¡¢±¾µØ±äÁ¿µÄÉùÃ÷ÖС£ÕâЩÐÅÏ¢±»´æ´¢ÔÚannotationµÄ“name=value”½á¹¹¶ÔÖÐ ......

Æô¶¯·ÇjavaÐéÄâ»ú·½Ê½ÏÂÔËÐÐmatlab

ÔÚ·ÇjavaÐéÄâ»úÏÂÔËÐÐmatlab¾Ý˵¿ÉÒÔÀ©´óÄÚ´æ,Æô¶¯·ÇjavaÐéÄâ»úÏÂÔËÐÐ matlabµÄ·½·¨ÓУº
Ò».
1¡¢ÓÒ½¨µãmatlab¿ì½Ý·½Ê½£¬Ñ¡ÊôÐÔ ......

Java ¶àÏ̱߳à³ÌÖ®Áù£ºÏß³ÌÖ®¼äµÄͨÐÅ£¨¸½Ô´´úÂ룩

Java ¶àÏ̱߳à³ÌÖ®Áù£ºÏß³ÌÖ®¼äµÄͨÐÅ£¨¸½Ô´´úÂ룩
Ô´´úÂëÏÂÔØ
       
¶àÏ̱߳à³ÌÖУ¬Ïß³ÌÖ®¼äµÄͨÐÅÊÇÒ»¸ö±È½Ï¸´ÔÓµÄÎÊÌâ¡£´ó¼ÒÍùÍù¸ã²»¶®Ê²Ã´ÊǾºÕù×ÊÔ´£¿Ê²Ã´Ê±ºò¿¼ÂÇͬ²½£¿Ôõô½øÐÐͬ²½£¿Ê²Ã´ÊÇÏß³ÌͨÐÅ£¿Ôõô½øÐÐͨÐÅ£¿ºÜ
¶àÅóÓÑÃæÊÔµÄʱºò¶¼Óöµ½¹ýÕâÑùÀàËƵÄÒ»¸ö±à³ÌÌ⣺¸ø¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ