package com.yh.test02;
public class Test {
public static void main(String[] args) {
Test.method1();
method1();
Test t=new Test();
t.method2();
t.method1();
}
public static void doSome(){
System.out.println("doSome方法执行");
}
public void doOther(){
System.out.println("doOther方法执行");
}
public static void method1(){
System.out.println("=========");
Test.doSome();
doSome();
Test t1=new Test();
t1.doSome();
System.out.println("method1方法执行");
t1.doOther();
}
public void method2(){
System.out.println("2=========");
Test.doSome();
doSome();
Test t2=new Test();
t2.doOther();
t2.doSome();
System.out.println("method2方法执行");
}
}
方法名上有static关键字用类名.方法名();
用方法名();
还可以用引用.方法名();
方法名上没有static关键字用引用.方法名();
引用指向了JVM的堆内存java对象
原文:https://www.cnblogs.com/god1/p/12036115.html