I was curious what public variables actually do. I assumed they work across all classes inside of a package, but apparently that is not the case. I want to know how to carry the ADD, and MULT variables over from the first class into the second class. Here is my code on the first class:
public class first {
public static int ADD = 0;
public static int MULT = 1;
public static int derp(int x, int x2, int a){
int septor = 0;
if(a == 0){
septor = x + x2;
}
if(a == 1 ){
septor = x * x2;
}
return septor;
}
}
The second class:
public class second {
public static void main(String args[]){
int y = first.derp(6,10,ADD);
System.out.println(y);
}
}