Using a non-static variable in a static method JAVA

前端 未结 4 2133
臣服心动
臣服心动 2021-01-17 06:12

So I am writing a very large java code, within this code I want it to output files in a particular file format. In this instance it is going to be a simple .txt file.

4条回答
  •  情书的邮戳
    2021-01-17 06:34

    you should know non-static method belongs to Object ,but static method belongs to Class.Therefore the getNonStaticVariables method and nonStaticVariable should be static or change the outputToTxt to non-static.

提交回复
热议问题