There are many questions on this site about this. I browsed through all of them and also the internet without finding a solution to my particular problem (or being able to see how they relate to it). Also, what might be unique here is that this is a java specific problem and it doesn't apply to c#. I do some thing really simple here (in java), create a class like so -
public class asdf{
public int aa;
public int bb;
public asdf(int i,int j){
aa=i;
bb=j;
}
}
Now I try to instantiate it from the main method of another class -
asdf aaaa = new asdf(1,2);
Here is the complete code in the test class -
public class test2 {
public class asdf{
public int aa;
public int bb;
public asdf(int i,int j){
aa=i;
bb=j;
}
}
public static void main(String[] args){
asdf aaaa = new asdf(1,2);
}
}
This line gives me the error - non static variable can't be referenced from a static context. What is static here? The main method is in a class that isn't static, non of the variables are static and I am creating an instance. So, whats the problem? Note also that this works perfectly well in C#. So, it seems to be a Java specific thing.