不,"this"关键字不能用来引用类的静态成员。这是因为"this"关键字指向类的当前对象,而静态成员不需要任何对象来调用。在Java中,可以直接访问类的静态成员而不需要创建对象。
public class StaticTest { static int a = 50; static int b; static void show() { System.out.println("Inside the show() method"); b = a + 5; } public static void main(String[] args) { show(); System.out.println("The value of a is: " + a); System.out.println("The value of b is: " + b); } }
Inise the show() method The value of a is: 50 The value of b is: 55