>
> Godmar Back wrote,
> > Miles Sabin wrote,
> > > [snip: className.class vs Class.forName("className")]
> >
> > In other words, you're saving a try/catch clause at the
> > expense of one hidden static variable.
>
> Hmm ... well, a litte more than that. The lookup is done
> only once (to initia
Godmar Back wrote,
> Miles Sabin wrote,
> > [snip: className.class vs Class.forName("className")]
>
> In other words, you're saving a try/catch clause at the
> expense of one hidden static variable.
Hmm ... well, a litte more than that. The lookup is done
only once (to initialize the static).
St
>
> > If you know the class' name, and I suspect that you do
> > since you are in a static method of the class, you can
> > do a Class.forName(className).
>
> Better still, className.class, and have it resolved at
> compile time rather than by a runtime lookup.
>
Miles, "className.class" is
> Weiqi Gao writes:
Weiqi> Jesper Nordenberg wrote:
>>
>> Is there any way to obtain the Class-instance associated with the
>> current class in a static method? Obviously, this.getClass() doesn't
>> work ;)
Weiqi> If you know the class' name, and I suspect that you d
> If you know the class' name, and I suspect that you do
> since you are in a static method of the class, you can
> do a Class.forName(className).
Better still, className.class, and have it resolved at
compile time rather than by a runtime lookup.
Cheers,
Miles
--
Miles Sabin
At 8:32 10 Oct 1999 -0500, Weiqi Gao wrote:
> Jesper Nordenberg wrote:
> >
> > Is there any way to obtain the Class-instance associated with the
> > current class in a static method? Obviously, this.getClass() doesn't
> > work ;)
>
Use the special variable 'MyClass.class'. (not in 1.0.2)
Pa
>This might be slightly off topic, but I really need help with this.
>
>Is there any way to obtain the Class-instance associated with the current
>class in a static method? Obviously, this.getClass() doesn't work ;)
>
If the class is call com.blah.Stuff, use com.blah.Stuff.class; to get the
jav
Jesper Nordenberg wrote:
>
> Is there any way to obtain the Class-instance associated with the
> current class in a static method? Obviously, this.getClass() doesn't
> work ;)
If you know the class' name, and I suspect that you do since you are in
a static method of the class, you can do a Class
Jesper Nordenberg wrote:
This might be slightly off topic, but I really need
help with this.
Is there any way to obtain the Class-instance associated with the current
class in a static method? Obviously, this.getClass() doesn't work ;)
You can use the static method Class.forName() on the Clas
> This might be slightly off topic, but I really need help with this.
>
> Is there any way to obtain the Class-instance associated with the current class in a
>static method? Obviously, this.getClass() doesn't work ;)
Pass in a reference to the class.
Nathan Ehresman
This might be slightly off topic, but I really need help with this.
Is there any way to obtain the Class-instance associated with the current class in a
static method? Obviously, this.getClass() doesn't work ;)
--
| Jesper Nordenberg, M.Sc. in C.S.E.NNL Technology AB
| E-mail: [EMAIL PROTEC
11 matches
Mail list logo