Can this keyword be used to refer static members in Java?

Yes, It is possible to use this keyword to refer static members because this is just a reference variable which refers to the current class object. However, as we know that, it is unnecessary to access static variables through objects, therefore, it is not the best practice to use this to refer static members. Consider the following example.

  1. public class Test
  2. {
  3.     static int i = 10;
  4.     public Test ()
  5.     {
  6.         System.out.println(this.i);
  7.     }
  8.     public static void main (String args[])
  9.     {
  10.         Test t = new Test();
  11.     }
  12. }

Output

10