1. "this"
is used to refer to the parent object of a variable or method. When you declare static
on a method the method can be called without needing to instantiate an object of the class. Therefore the "this"
keyword is not allowed because your static method is not associated with any objects. 2. Keyword "this" refers to the object that you are operation with. In your case "this" inside any non-static methods or constructor, then "this" refers to that particular instance of the class Sub.So it is applicable only when the object is created. But anything in the static context of a class, you can use without even creating object for that as it is resolved during the class loading. "this" resolved only when object is created ( you can even say dynamically for which object). So "this" make sense in static context
3. this :- "this" means current class OBJECT , so its clear that "this" only come in the picture once we intended to create an Object of that class.
static method:- there is no need to create an object in order to use static method. means "instance" or object creation doesn't any sense with "static" as per Java rule.
So There would be contradiction,if we use both together(static and this) . That is the reason we can not use "this" in static method.