🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8731

Re: class reference from static context

#8731
From: Torsten Welches
Date: Thu, 01 Mar 2001 06:41
17 lines
1480 bytes
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: <3a9def0f$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!207.105.83.65
References: <97knfi$fdt3@bornews.inprise.com>

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-02-28 22:48:05 PST
From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Sender: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Reply-To: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Subject: Re: class reference from static context
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 193.158.55.74 193.158.55.74    
References:  <97knfi$fdt3@bornews.inprise.com> 
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3a9def0f$1_2@dnews>
Date: 28 Feb 2001 22:41:19 -0800
X-Trace: 28 Feb 2001 22:41:19 -0800, 207.105.83.65
Lines: 18
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!207.105.83.65