this: Cannot use this in static context

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

    writing this means in static context we are expecting to return the address of the object. Though its totally legal to have an object calling static methods but it is not an obligation. So compiler stops possibility of any error in case object is not created for the class.

提交回复
热议问题