this: Cannot use this in static context

后端 未结 5 555
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 12:10

Can you please help me with below code. The error is: \"Cannot use This in a static context\"

public class Sample2 {
    /**
     * @param a         


        
5条回答
  •  迷失自我
    2020-11-28 12:38

    In java you can not use this in static methods (static context).

    Static methods do not point to any instance of the enclosing class.

    A static method cannot refer to “this” or “super” keywords in anyway

    Refer official docs on this keyword

提交回复
热议问题