Static Context
Alright, this problem is a little difficult to explain. It's for an RPG game. Spell is a working class (builds me a new variable)
publicclass Setup
{
String dats[] =new String[10];
publicvoid loadDat()
{
/*code for opening data file is unimportant, assume it works and is a string in dats[0]*/
}
public Spell getSpell(String a)//This returns a spell based on ID tag
{
//this searches through dats[0] for "a" and builds a Spell that it declares as foundspell; assume it works
return foundspell;
}
//This returns an ArrayList of spells (of one type) that the user can cast
public ArrayList searchSpell(int type,int req)
{
ArrayList spells =new ArrayList();
/*this uses "getSpell()" to search the dats[0] for certain requires; assume it works as intended as puts all the spells into spells*/
return spells;
}
}
loadDat() is executed as the start of the program (in another class).
So, I need it to be non-static because I need the dats[0] to be accessible always (without running it everytime searchSpell() is called). But when I call searchSpell() from another class (that's not always static, its non-static too) it says: "non-static method cannot be referenced by a static context". If i declare everything as static (the methods above). It says hte same error, but points at the variable dats[0].
Any thoughts?
Sorry it's so confusing, if anyone has any idea, please tell, I can probably add more details if you think you need to know something I didn't write in.

