A friend recently told me about the variable .class that can be used on
any Class as in String.class or Hashtable.class, but not on instances of
classes (e.g., String str = "Nat"; Class cls = str.class; // fails).

I've had trouble finding documentation about this variable in the
JavaDoc's though I was told it is part of the specifications.  One use
(other than being neater than (new WhateverClass().getClass()) is to allow
static methods to name the class where they are being run (e.g., in places
where you'd want a "this" variable) -- for example, when logging errors
and wanting to name the Class / method where the error occurred.

I hope you find knowing about .class useful.  Apparently, it is part of
the Class class as a member variable named .class (say that 5 times
fast...).

Best Regards, Nat

Attachment: smime.p7s
Description: application/pkcs7-signature

____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

Reply via email to