static or not?



There are many situations when one has a Class for
which it only makes sense that a single instance be
created in a given session. It seems to me that, in
this situation, it does not really make much
difference whether the Class's variables are declared
as static or not. There is still only going to be one
instance of each anyway. I have determined by
experiment that such a program compiles and works the
same either way. (I have encountered a couple
situations where the compiler was not happy until I
made a certain variable static because I had
referenced it from a static context. But such
situations are rare for me.)

My question: When you have the choice, which choice
should you make? My guess is that static declarations
may lead to more efficient code; but I have been
unable to find any discussion of this issue. (Part of
the problem here is that Sun's search on "static" hits
just about everything. Its concept of relevance seems
pretty weak.) If it makes no difference, then I see
no point in cluttering the code with unnecessary
"static" key words.

I could use some guidance on this issue.

Any pointers appreciated,
David V.


.