Java֮staticѧϰ
¶ÔÓÚѧϰstaticÎÒÃÇÏÈÀ´¿´Á½¸öÀý×Ó£º
//Example 1 Tst.java£¬no main() method
package com.blogchina.qb2049;
public class Tst
{
static { System.out.println("111111"); }
}
ÔËÐнá¹ûΪ: 111111
Exception in thread "main" java.lang.NoSuchMethodError: main
ͬÑùµÄµÀÀí¿´µÚ¶þ¸öÀý×Ó£º
//Example 2 TFrame.java,no main() method
package com.blogchina.qb2049;
import javax.swing.JFrame;
public class TFrame
{
static {
JFrame jfr_fr= new JFrame("ÎÞmain£¨£©´°Ìå");
jfr_fr.setLocation(400,300);
jfr_fr.setSize(200,300);
jfr_fr.setVisible(true);
jfr_fr.setDefaultCloseOperation(jfr_fr.EXIT_ON_CLOSE);
}
}ÔËÐнá¹ûÈçÏÂͼ£º
Õâµ½µ×Ôõô»ØÊ£¬Õâ²»ºÍÎÒÃÇ´ó¶àÊý½Ì³Ì½éÉܵÄÎÞmain£¨£©·½·¨³ÌÐòËÆºõ²»ÄÜÔËÐÐÏàì¶ÜÂð¡£Æäʵ£¬ÕâÆäÖеÄÔµÓɾÍÔÚÓÚÄǸöstaticµÄÐÞÊΡ£ÎÒ
ÔÚѧϰjavaʱ£¬staticµÄѧϰÈÃÎÒºÜÊÜÆô·¢£¬Ìش˰ÑËüµÄ×ܽáÈçÏ£¬Ï£Íû¶ÔÏëѧϰjavaµÄÅóÓÑÓÐËù°ïÖú¡£Í¬Ê±£¬±¾ÎÄÖеIJ»×㻹ϣÍû´ó¼Ò¶à¶àµÄÌá³ö
À´£¬ÎÒÃǹ²Í¬Ñ§Ï°¡£
ѧϰ±¾ÎÄÄãµ½µ×Ҫѧµ½Ê²Ã´£º
1¡¢ staticÔÚjavaÖе½µ×´ú±íʲô£¬ÎªºÎÒªÓÃËü£¿
2¡¢ staticÔÚjavaÖÐÔõôÓã¿
3¡¢ static ÓÐÄÇÐ©ÌØµãºÍʹÓõē¾ÖÏÞ”£¿
1¡¢ staticÔÚjavaÖе½µ×´ú±íʲô£¬ÎªºÎÒªÓÃËü£¿
static¨D¨D¾²Ì¬¨D¨D“Ö¸¶¨Î»ÖÓ
Ê×ÏÈ£¬ÎÒÃÇÀ´¿´¿´javaµÄÄڴ棺java°ÑÄÚ´æ·ÖΪջÄÚ´æºÍ¶ÑÄڴ棬ջÄÚ´æÓÃÀ´´æ·ÅһЩ»ù±¾ÀàÐ͵ıäÁ¿ºÍÊý×é¼°¶ÔÏóµÄÒýÓñäÁ¿£¬¶ø¶ÑÄÚ´æÖ÷ÒªÊÇÀ´·ÅÖöÔÏóµÄ¡£
ÓÃstaticµÄÐÞÊεıäÁ¿ºÍ·½·¨£¬Êµ¼ÊÉÏÊÇÖ¸¶¨ÁËÕâЩ±äÁ¿ºÍ·½·¨ÔÚÄÚ´æÖеē¹Ì¶¨Î»ÖÔ£static
storage¡£¼ÈȻҪÓГ¹Ì¶¨Î»ÖÔÄÇôËûÃǵē´óС”ËÆºõ¾ÍÊǹ̶¨µÄÁË£¬ÓÐÁ˹̶¨Î»Öú͹̶¨´óСµÄÌØÕ÷ÁË£¬ÔÚÕ»Öлò¶ÑÖпª±Ù¿Õ¼äÄǾÍÊǷdz£µÄ·½±ãÁË¡£
Èç¹û¾²Ì¬µÄ±äÁ¿»ò·½·¨ÔÚ²»³öÆä×÷ÓÃÓòµÄÇé¿öÏ£¬ÆäÒýÓþä±úÊDz»»á·¢Éú¸Ä±äµÄ¡£
ÎÒÃdz£¿´µ½£ºstatic±äÁ¿ÓеãÀàËÆÓÚCÖеÄÈ«¾Ö±äÁ¿µÄ¸ÅÄ¾²Ì¬±íʾµÄÊÇÄÚ´æµÄ¹²Ïí£¬¾ÍÊÇËüµÄÿһ¸öʵÀý¶¼Ö¸Ïòͬһ¸öÄÚ´æµØÖ·¡£°Ñ
staticÄÃÀ´£¬¾ÍÊǸæËßJVMËüÊǾ²Ì¬µÄ£¬ËüµÄÒýÓ㨺¬¼ä½ÓÒýÓã©¶¼ÊÇÖ¸Ïòͬһ¸öλÖã¬ÔÚÄǸöµØ·½£¬Äã°ÑËü¸ÄÁË£¬Ëü¾Í²»»á±ä³ÉÔÑù£¬Äã°ÑËüÇåÀíÁË£¬Ëü
¾Í²»»á»ØÀ´ÁË¡£ÎÒÃdz£¿É¿´µ½ÀàËÆÒÔϵÄÀý×ÓÀ´ËµÃ÷Õâ¸öÎÊÌ⣺
cla
Ïà¹ØÎĵµ£º
̸̸»Øµ÷°É£¬ÒÔǰѧjavaµÄʱºò¾ÓȻû½Ó´¥µ½Õâ¸ö´Ê»ã£¬º¹£¬×î½üÑо¿hibernateºÍspring½áºÏʱ£¬·¢ÏÖspringʵÏÖhibernateʱӦÓÃÁ˻ص÷»úÖÆ£¬ÓÚÊÇgoogleÁ˺ܶà´Î£¬ÖÕÓÚÓÐËùÌå»áÁË£¬ÏÖÔÚ×öÏÂССµÄ×ܽᣬÒÔ±ã¼ÓÉîÓ¡Ïó£¡
java»Øµ÷»úÖÆ£º
Èí¼þÄ£¿éÖ®¼ä×ÜÊÇ´æÔÚ×ÅÒ»¶¨µÄ½Ó¿Ú£¬´Óµ÷Ó÷½Ê½ÉÏ£¬¿ÉÒÔ°ÑËûÃÇ·ÖΪÈý ......
/*
±¾¶Î´úÂëÔÚ¹«Ë¾ÏîÄ¿ÖÐʵ¼ÊÔ¶³Ìµ÷ÓõÚÈý·½¹«Ë¾ÌṩµÄC#¿ª·¢WebServiceµÄʾÀý
*/
/**
* µÇ¼ÓÎÏ·
*
* @param paramPN
* @param paramTerraceID
* @param paramSvrID
*/
private String loginGame(String paramPN, HttpServletRequest req){
&n ......
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......
¾ÙÀý×Ó˵Ã÷Ò»ÇС£
JAVA_HOME£º C:\j2sdk1.4.2_13
Path£º C:\j2sdk1.4.2_13\bin;
Classpath£º.;JAVA_HOME\lib\tools.jar ; JAVA_HOME\lib\dt.jar;
&n ......
Ŀ¼
1. ¼ò½é
2. °²×°
3. log4j»ù±¾¸ÅÄî
3.1. Logger
3.2. Appender
3.2.1. ʹÓÃConsoleAppender
3.2.2. ʹÓÃFileAppender
3.2.3. ʹÓÃWriterAppender
3.3. Layout
3.4. »ù±¾Ê¾Àý
3.4.1. SimpleLayoutºÍFileAppender
3.4.2. HTMLLayoutºÍWriterAppender
3.4.3. PatternLayoutºÍConsoleAppender
4. ʹÓÃÍⲿ ......