定义一个测试类,在main()方法中输出staticField的值,并且调用静态方法staticMethod()
时间: 2024-06-04 18:12:46 浏览: 68
public class TestClass {
static int staticField = 10;
public static void main(String[] args) {
System.out.println(staticField);
staticMethod();
}
public static void staticMethod() {
System.out.println("This is a static method.");
}
}
阅读全文