non-static method cannot be referenced from a static context

后端 未结 5 1784
無奈伤痛
無奈伤痛 2020-12-10 09:36

I would like to understand this once and for all.

With this please excuse the mass of code pasted below, but I do not want to leave out any details.

The only

5条回答
  •  我在风中等你
    2020-12-10 09:45

    You need to make your function static:

    public static HashMap readPositions(String destFile) {
    ...
    }
    

    Creating an instance of GarageComm would work too, but this is bad programming practice in Java, since that object has no state.

提交回复
热议问题