🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Another Java Puzzlet

#7571
From: Mark Griffiths
Date: Fri, 08 Jun 2001 13:21
37 lines
1980 bytes
How about the following?  The class 't' does not have a static main(), but
before the JVM can find that out, it must load the class.  When a class is
loaded, it's static initializers are executed... bingo!

// begin t.java
import java.awt.*;
class t {
   static {
      Frame f = new Frame();
      f.add(new Label("Hello, World!"));
      f.pack();
      f.show();
   }
}
// end t.java

--
Mark

"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:MPG.158a2ccca5eb796e98a27f@forums.borland.com...
>
> Here is another little Java Puzzle that occurred to me:
>
> Write a Java Application (i.e. Java code that can be run from the
> command line using the "java" command) that displays a small window
> with the text "Hello, World!".  The catch:  the program cannot have
> a static method named "main".
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3b20d156$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews
References: <MPG.158a2ccca5eb796e98a27f@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,aad772bb962488c
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-08 06:44:19 PST
From: "Mark Griffiths" <DONT.SPAM.mark@chive.com>
Newsgroups: borland.public.jbuilder.java.language
References: <MPG.158a2ccca5eb796e98a27f@forums.borland.com>
Subject: Re: Another Java Puzzlet
Date: Fri, 8 Jun 2001 14:21:49 +0100
Lines: 39
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
NNTP-Posting-Host: 213.122.182.200
Message-ID: <3b20d156$1_1@dnews>
X-Trace: dnews 992006486 213.122.182.200 (8 Jun 2001 06:21:26 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews