首页 > 其他 > 详细

static

时间:2021-07-15 23:51:55      阅读:29      评论:0      收藏:0      [点我收藏+]
package Dome;
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);
  }
}
package Dome;
?
public class Person {
  {//付初始值
      System.out.println("匿名方法快");
  }
  static {//静态方法只执行一次
      System.out.println("构造方法快");
  }
?
  public Person() {
      System.out.println("无参构造");
  }
?
  public static void main(String[] args) {
      Person s1 = new Person();
      System.out.println("=======");
      Person s2 = new Person();
?
?
  }
}
package Dome;
?
public class Dome07 {
  public static int age;//静态方法
  public double score;//非静态方法
?
  public static void main(String[] args) {
      Dome07 s1 = new Dome07();
      System.out.println(Dome07.age);
      System.out.println(s1.age);
      System.out.println(s1.score);
      new Dome07().run();
  }
  public static void go(){
?
  }
  public void run(){
?
  }
?
?
?
}

+++

static

原文:https://www.cnblogs.com/java5745/p/15017822.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!