non-static method toString() cannot be referenced from a static context

后端 未结 4 2008
长发绾君心
长发绾君心 2020-12-10 20:03

Don\'t want any code, just want some sort of guidance. Would like to keep my academic integrity in tact ;)

I keep getting that annoying error. I need to call the toS

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 20:22

    What you're probably doing is calling toString() on the class Room, not an instance of it. For example, instead of writing:

    Room.toString()
    

    write:

    Room r = new Room()
    r.toString()
    

提交回复
热议问题