public class Main {
public static void main(String[] args) {//N o w J a v a . c o m - 时 代 Java
MyClass mt = new MyClass();
System.out.println("Invoking instance method...");
mt.printMN();
System.out.println("Invoking class method on class name...");
MyClass.printM();
System.out.println("Invoking class method on an instance...");
// Invoke the class method using the instance reference
mt.printM();
}
}
class MyClass {
static int m = 100; // A static variable
int n = 200; // An instance variable
static void printM() {
System.out.println("printM() - m = " + m);
/**
from
* nowjava.com - 时 代 Java
**/
}
void printMN() {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。