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
Ïà¹ØÎĵµ£º
µÚ5ÕÂͼÐνçÃæÉè¼Æ(Ò»)
(Ò»)¿Î³ÌÄÚÈÝ
5.1 ͼÐνçÃæÉè¼Æ»ù´¡
5.1.1 AWI’ºÍSwing
5.1.2×é¼þºÍÈÝÆ÷
5.1.3ʼþÇý¶¯³ÌÐòÉè¼Æ»ù´¡
5.2¿ò¼Ü´°¿Ú .
5.3±êÇ©¡¢°´Å¥ºÍ°´Å¥Ê¼þ
5.3.1 ±êÇ©
5.3.2°´Å¥ºÍ°´Å¥Ê¼þ´¦Àí
5.4Ãæ°å
5.4.1 JPanel
5.4.2 JScrollPane
5.5²¼¾ÖÉè¼Æ
5.5.1 FlowI.ayout²¼¾Ö
5.5.2 BorderI.a ......
µÚ8Õ ¶àÏß³Ì
(Ò»)¿Î³ÌÄÚÈÝ
8.1Ï̵߳Ļù±¾¸ÅÄî
8.1.1Ï̵߳ÄÉúÃüÖÜÆÚ
8.1.2Ï̵߳÷¶ÈÓëÓÅÏȼ¶
8.2 ThreadÀàºÍRunnable½Ó13
8.2.1 ThreadÀà
8.2.2 Runnable½Ó¿Ú
8.3Ï̻߳¥³âºÍͬ²½
8.3.1Ï̻߳¥³â
8.3.2Ïß³Ìͬ²½
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉܶàÏ̵߳ĸÅÄîºÍ±àд¶àÏ̳߳ÌÐòµÄ·½·¨£¬ÊµÏÖÏß³ÌÖ®¼äÏ໥ͨÐźÍͬ²½µÄ¼¼ ......
1£®JavaµÄ¼òµ¥ÀàÐͼ°Æä·â×°Æ÷Àà
¢ÅJava¼òµ¥ÀàÐÍÓë·â×°Àà
ÎÒÃÇÖªµÀ,JavaÓïÑÔÊǵäÐ͵ÄÖ§³ÖÃæÏò¶ÔÏóµÄ³ÌÐòÓïÑÔ,µ«¿¼Âǵ½ÓÐЩ»ù±¾Êý¾ÝÀàÐ͵Ľṹ¼òµ¥,Õ¼ÄÚ´æСÇÒ´æÈ¡ËٶȿìµÈÓŵã,JavaÒÀÈ»ÌṩÁ˶ÔÕâЩ·ÇÃæÏò¶ÔÏóµÄ¼òµ¥Êý¾ÝÀàÐ͵ÄÖ§³Ö¡£µ±È»,JavaÔÚÌṩ´óÁ¿µÄÆäËüÀàʱ,Ò²ÌṩÁËÓë¼òµ¥Êý¾ÝÀàÐͶÔÓ¦µÄ·â×°Àà,ÓÚÊÇ,JavaÖ ......
´úÂëÈçÏ£º
1 String command = " cmd /c C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqldump -h localhost -u root -p aijia > E:/aijia.dmp " ;
2 try {
3 Process process& ......
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......