Article View: borland.public.jbuilder.java.language
Article #8733Re: class reference from static context
From: Rick Ingham
Date: Thu, 01 Mar 2001 07:54
Date: Thu, 01 Mar 2001 07:54
20 lines
1769 bytes
1769 bytes
But will that work in subclasses that inherit the method and properly reflect the subclass' class name?
"Torsten Welches" <torsten.welches@who.cares.netcologne.de> wrote in message news:3a9def0f$1_2@dnews...
>
> Rick,
>
> use the "YourClass.class" syntax.
>
> Torsten
>
> "Rick Ingham" <rdingham@home.com> wrote:
> >I want to be able to reference the Class object of a class from a static method. I try:
> > public static DEBUG() {
> > System.out.println(this.getClass().getName() );
> > }
> >
> >But teh compiler tells me the "this" can't be referenced in a "static" context.
> >
> >Seems like there should be a way to get to hte Class of the class from a sttic method without instantiating an instance of the
> >object.
>
Technical Details
Message-ID:
<97kv03$2m31@bornews.inprise.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!bornews.borland.com!not-for-mailReferences:
<97knfi$fdt3@bornews.inprise.com> <3a9def0f$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f19fee463664b3b0 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-01 00:13:10 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!bornews.borland.com!not-for-mail From: "Rick Ingham" <rdingham@home.com> Newsgroups: borland.public.jbuilder.java.language Subject: Re: class reference from static context Date: Wed, 28 Feb 2001 23:54:18 -0800 Organization: Another Netscape Collabra Server User Lines: 21 Message-ID: <97kv03$2m31@bornews.inprise.com> References: <97knfi$fdt3@bornews.inprise.com> <3a9def0f$1_2@dnews> NNTP-Posting-Host: c191422-a.sttln1.wa.home.com Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400