When are classes loaded by other classes?

From: Hal Vaughan (hal_at_thresholddigital.com)
Date: 06/28/04


Date: Mon, 28 Jun 2004 14:07:53 -0400

If I have a class like this:

public class Tester {

        ObjectType1 ot1;
        ObjectType2 ot2;
        ObjectType3 ot3;

        public void main(String args) {
                //Preliminary checking, resulting in bRun being
                //true or false -- true means we continue, false, we quit:
                if (bRun) {
                        Tester t = new Tester();
                        t.doStuff();
                }
                System.exit(0);
        }

        public Tester() {
                //do stuff to create an instance of this class
                ot1= new ObjectType1;
                ot2= new ObjectType2;
                ot3= new ObjectType3;
                return;
        }

        public void do Stuff() {
                //main processing routines to do stuff in this object
                return;
        }
}

Does this class load the files for the classes ObjectType1, 2, and 3 when
this class is first called from the command line, or does it wait and load
those classes from disk when the main() method calls Tester() to create an
object? In other words, if bRun is false, and the main() method never
creates an object of type Tester, are the other classes ever loaded?

I'm concerned about speed and trying to create a small class to determine
whether another class, that uses a good number of objects (like
ObjectType1, 2, & 3 are used above) needs to run. I won't have to create
an extra class if I can keep a long list of objects from loading until the
main() method actually creates the object.

Thanks!

Hal



Relevant Pages

  • Changing User Directory path
    ... Assign a Home Directory to a User from the Command Line ... You can use the net user command to assign a home ... assign the tester$ hidden shared folder on the server that ...
    (microsoft.public.win2000.active_directory)
  • Re: battery hydrometer
    ... that testing under load with a DVM was the way to go. ... tester doesn't necessarily equal the load of your starter motor. ... They do put a heavy load on a battery, and as long as the volts don't ... When first connected it simply reads the no-load battery voltage. ...
    (uk.rec.cars.maintenance)
  • Re: battery hydrometer
    ... that testing under load with a DVM was the way to go. ... tester doesn't necessarily equal the load of your starter motor. ... They do put a heavy load on a battery, and as long as the volts don't ... When first connected it simply reads the no-load battery voltage. ...
    (uk.rec.cars.maintenance)
  • Re: battery hydrometer
    ... that testing under load with a DVM was the way to go. ... tester doesn't necessarily equal the load of your starter motor. ... They do put a heavy load on a battery, and as long as the volts ... When first connected it simply reads the no-load battery voltage. ...
    (uk.rec.cars.maintenance)
  • Re: battery hydrometer
    ... that testing under load with a DVM was the way to go. ... tester doesn't necessarily equal the load of your starter motor. ... They do put a heavy load on a battery, and as long as the volts ... When first connected it simply reads the no-load battery voltage. ...
    (uk.rec.cars.maintenance)