Non-static method of 〇〇 Cannot be statically referenced

Note that I got stuck when I tried to use the function used in the previous programming in the new environment

I was angry with Eclipse when I wrote the following as usual.

function


msgStr = MsgList.getMsg("hoge", hoge);

無題.png

Static I don't want to refer to this message, but it doesn't disappear.

When I looked up the solution, it was an error that came from a simple mistake.

Solution

Instantiate a function. Use an instantiated function.

Instantiated function


MsgList msgList = new MsgList();
msgStr = msgList.getMsg("hoge", hoge);

This solved it.

It's just a mistake, but maybe it's the path most people take. It took me quite a while to resolve it, but I hope it helps.

Recommended Posts

Non-static method of 〇〇 Cannot be statically referenced
[Rails 6] method :: delete cannot be used with link_to
definition of ruby method