A static method belongs to the class, a non-static method belongs to an instance of the class.
When you call getCurrentValue()
from main
, you get an error because main
isn't associated with any instance.
You need to create an instance of the class:
HallLanceMemoryCalculator me = new HallLanceMemoryCalculator();
Then you can call the instance's getCurrentValue()
:
double value = me.getCurrentValue();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…