this: Cannot use this in static context

后端 未结 5 568
爱一瞬间的悲伤
爱一瞬间的悲伤 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:29

    They keyword this refers to the instance of the class. In a static context, you have no instance, therefore you can't refer it.

    For more information, refer to this answer: What is the meaning of "this" in Java?

提交回复
热议问题