So I seem to be struggling a little bit with static in general. What exactly does static do in Java and how do you fix it? For example, here is a bit of code
public class StaticProblem
{
static int number;
static int valOne, valTwo, valThree;
public static void main(String args)
{
// stuff
valOne = method1(number);
valThree = method2(val1, val2);
}
public static int method1(int parameter)
{
int var;
// stuff
return parameter + var;
}
public static int method2(int parm1, int parm2)
{
int othervar;
// more stuff
return parm1 + parm2 + othervar;
}
:
}
How exactly would one go about fixing the "static" problem so that static is no longer used. I sort of understand that static in Java allows the value of one object to be shared with new objects that are created (for example, 15 cards all share the same gas left in the tank - if one car goes empty, then the rest go empty as well). I thought I knew how to fix this code and I assumed it involved making a new StaticProblem object in the main method. However, I am a bit lost.