Static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,也可以形成静态static代码块,被static修饰的成员变量和成员方法独立于该类的任何对象。
也就是说,它不依赖类特定的实例,被类的所有实例共享。只要该类加载,JVM虚拟机就能根据类名在运行时数据区的方法区内找到他们。因此,static对象可以在它的任
何对象创建之前访问,无需引用任何对象。
1、static修饰类的成员方法或者成员变量,我们通常称该方法是静态方法,该方法是静态变量;
若用public修饰static成员方法或者成员变量,表示该方法或该变量是全局的,可以在其他类中通过类名直接调用;
若用private修饰static成员变量,表示该变量只能在该类的成员方法中使用,并且可以在该类的静态代码块中使用;
在静态方法或者静态代码块中只能调用静态变量,但在非静态方法或者代码块中可以调用静态和非静态的变量。
2、静态代码块 非静态代码块 构造函数的加载顺序
静态代码块,在虚拟机加载类的时候就会加载执行,而且只执行一次
非静态代码块,在创建对象的时候(即new一个对象的时候)执行,每次创建对象都会执行一次
public class StaticTest {
static {
System.out.println("static function...");
}
{
System.out.println("unstatic function...");
}
public StaticTest(){
System.out.println("construct function...");
}
public static void main(String[] args) {
new StaticTest();
}
}
运行结果: aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO8AAABLCAIAAAAXn0cWAAAER0lEQVR4nO2dzZWjMBAGicsBEQ/RkIxPc9kQ9uo5eLAlpJZaf8Brqo5GQINqZK2s7+308+//q4bn8pimx/Iccu46T1P11ZOs86ALpzjxee/FdEmbh7HO0zTN68F3Pe95b8YNbT7+xth8EAmbn8tj2vh2hfupjzPk+Y0+BxTnvr9zwysKdZWOs4LNwZDtfbCd5NQW3jZWVY/nFRuoqroZks27+eVzmXcOJMabdXY+f79s/z0rxiphSvD2w7u8pgs9JRy2C+Vtdm0JWueqqn1evxN2d8lWdUMEm/PvX/3tGWlY27vt39jVY7N32G/e5V1FnjdyltsqU9UtSY7NqS7QmxUaVGlzh+lnvc3iUUVVVc8bO8n9LF3VPSmeN3tHhR4K54tdbO7QXQNsVlRVb3Ns7oHNIoo1jc1N5dz33Xz3DcjYzNh8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静态代码块>类构造函数
注:非静态代码块在不new类的时候是不是执行的。
如果有多个静态代码块,执行顺序是按照代码块的先后顺序执行。
2、静态变量
public class StaticTest { static String a="string-a";
static String b;
String c = "string-c";
String d;
static{
System.out.println("----------------------------");
}
static {
System.out.println("static function...");
privateStaicString("befor static");
b="string-b";
privateStaicString("after static");
}
{
System.out.println("unstatic function...");
privateStaicString("befor unstatic");
b="string-b";
privateStaicString("after unstatic");
} public StaticTest(){
System.out.println("construct function...");
privateConstructtring("befor construct");
d="string-d";
privateConstructtring("after construct");
}
public static void privateStaicString(String title) {
System.out.println("---------" + title + "---------");
System.out.println("a="+a);
System.out.println("b="+b);
}
public void privateConstructtring(String title) {
System.out.println("---------" + title + "---------");
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("c="+c);
System.out.println("d="+d);
}
public static void main(String[] args) {
new StaticTest();
}
}
运行结果: aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXcAAAJMCAIAAACO93FaAAAf1ElEQVR4nO3dyWHcPJAGUMflgBSPo1EyPs1lQpir5mD3by5YCZbYJN47ir2wIeETyCarfvzP//7fF0CYH1IGCCVlgFhSBoglZYBYUgaIJWWAWFIGiCVlgFhSBoglZYBYUgaIJWWAWNmU+f3r54+Vj09bbbW1cytf1jJANCkDxJIyQCwpA8SSMkAsKQPEkjJALCkDxJIyQCwpA8SSMkAsKQPEkjJArPdMmc+PHz9+/Pj563fci7/V/bOhnxcudjhlfv/6eXheVJ8bN+s+Py6Yzhd+Xrjee6ZMmM+PK9Yv131eeAMTpsz3v7GUYWqFlFnWAPs3RXaVwVKnONYP+m9Dw3MbTpqsXqVzXZJJmd0SZ/WD15MW+7Z/29RenfF5sw9o2it4A7mU2Zy/+P3rYzM3C/+fPz8WP/8zCdZ//w3/2zOHNn/m7erlW6bWaqouvF6onjLLWbx7dG2vjn7e9S9h8y7VvYI3kUmZ+rxoPgpIPPDorBs/8ji8llltXj/8lLFKfN7Es5aPquwVvI3iWqY0Ndpn/H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sz/50frzHpaD4PUE9pHA2ZXqi+TmYXT9TBwhAcj0ikzNq2e1sNAyMCIoA62D+9hALQ7sJaZroeBtQyMyJyXOfHf9/17GFjMwIjsd0yJk6ntrRif1cPga2Q0YHql62XSbQYaPK2HQWGHgZo73i15gB4GcJk5UkYPA7jOHCmjhwFcZ5KU+dLDAK4yT8oA15AyQCwpA8SSMkAsKQPEakyZVyG6t3B5dfG3Gg14d5ekzN17GEgZ6HDHlLmclIEOUuYAKQMdCimzvYm5Z149r4fByGjA1ErVxTdlE5rn1eN6GAyNBswuX/d3NY2WP5iuh0FxNICKZMrsp2D/WuY5PQwGRwNml02Z9SzqnVdP6mEwPhowtQMpM1sPAykDQ5Ips53r3Q1fdy925x4Gp44GzKfej+n3r58/fn58/GyeV4/rYTA0GjC9SqeU17HF6zqWNs/rYTAyGjC5Se7J1sMALjNHyuhhANeZI2X0MIDrTJIyX3oYwFXmSRngGlIGiCVlgFhSBoglZYBYUgaIJWWAWFIGiCVlgFhSBoglZYBYUgaIJWWAWFIGiCVlgFhSBoj1/9RnOt8BRbXsAAAAAElFTkSuQmCC" alt="" />
3、static和final一块使用
static final用来修饰成员变量和成员方法,可简单理解为“全局常量”!
(1)对于变量,表示一旦给值就不可修改,并且通过类名可以访问
(2)对于方法,表示不可覆盖,并且可以通过类名直接访问。