摘要:
静态方法中只允许访问静态数据,如果在静态方法中访问类的实例成员,即没有附加static关键字的字段或方法,可以在静态方法中创建类对象,用类对象访问类的非静态成员 package test2; public class Demo2 { public static void main(String[] 阅读全文
posted @ 2022-10-02 21:55
ashuai~
阅读(49)
评论(0)
推荐(0)
摘要:
package test2; class Root { static { System.out.println("Root的静态初始化块"); } { System.out.println("Root的普通初始化块"); } public Root() { System.out.println("R 阅读全文
posted @ 2022-10-02 21:35
ashuai~
阅读(20)
评论(0)
推荐(0)
摘要:
package test2; public class InitializeBlockDemo { /** * @param args */ public static void main(String[] args) { InitializeBlockClass obj=new Initializ 阅读全文
posted @ 2022-10-02 21:22
ashuai~
阅读(21)
评论(0)
推荐(0)
摘要:
package test2; public class Demo2 { public static void main(String[] args) { Foo obj1 = new Foo(); } } class Foo { int value = 100; public Foo(int val 阅读全文
posted @ 2022-10-02 21:05
ashuai~
阅读(52)
评论(0)
推荐(0)
摘要:
试验 package test2; public class Demo2 { public static void main(String[] args) { Foo obj1 = new Foo(); Foo obj2 = new Foo(); System.out.println(obj1 == 阅读全文
posted @ 2022-10-02 20:55
ashuai~
阅读(20)
评论(0)
推荐(0)