解決Python web框架(如Flask)與vue渲染變數的衝突(衝突會導致vue渲染報錯,網頁無法顯示)
阿新 • • 發佈:2021-09-05
static關鍵字詳解
與類一起執行
只執行一次
public class Person { //2: 賦初始值 { System.out.println("匿名程式碼塊"); } //1: 只執行一次 static{ System.out.println("靜態程式碼塊"); } public Person(){ System.out.println("構造方法"); } public static void main(String[] args) { Person person = new Person(); System.out.println("=============="); Person person1 = new Person(); } }
靜態匯入包
import static java.lang.Math.random;
import static java.lang.Math.PI;
public class Test {
public static void main(String[] args) {
System.out.println(random());
System.out.println(PI);
}
}
靜態與非靜態的區別
public class Student { private static int age;//靜態變數 private double score; //非靜態變數 //非靜態方法 public void run(){ } //靜態方法 public static void go(){ } public static void main(String[] args) { Student.go(); go(); new Student().run(); } }