I’ve been doing Java since 1998, and yet I only just discovered this interesting fact. If you have a class called, say, DBAsset that has a bunch of static methods in it, and you have some static member variables, and you initialize the static member variables, like so:
class DBAsset
{
static PreparedStatement insertStmt = null;
static PreparedStatement deleteStmt = null;
Then calling multiple static methods from within DBAsset’s static main using just the unadorned method name doesn’t do anything to those variables, but each time you call one of those static methods from some other class using DBAsset.methodname, those static variables get reinitialized to null. Huh.
Update: Figured it out. The code that initialized the variables was getting called *before* the code that set it to null, because I had a static DBAsset theAsset = new DBAsset();
before the static initializers. I’m such a slaphead.