[5899] in java-interest
Re: The dumbest (Mac) Java question ever...
daemon@ATHENA.MIT.EDU (Greg Ewing)
Mon Mar 4 00:50:27 1996
Date: Mon, 4 Mar 1996 11:32:46 +1100
From: grege@optimation.com.au (Greg Ewing)
To: java-interest@java.sun.com
Cc: solkode@ucunix.san.uc.edu
> From NewsGroup_comp-lang-java Tue Feb 27 10:27 EST 1996
> From: NewsGroup_comp-lang-java
> >From: solkode@ucunix.san.uc.edu (Dave's not here)
> Subject: Re: The dumbest (Mac) Java question ever...
> Date: 26 Feb 1996 21:02:52 GMT
> Nntp-Posting-Host: ucwkf.san.uc.edu
>
> In article <4gn7r3$1u4@malasada.lava.net>, jordy@lava.net (Jordy) wrote:
> <Snip>
> > Applets need more than this to work. Here is a complete example of an applet.
> >
> > import java.awt.Graphics;
> > public class HelloWorld extends java.applet.Applet {
> > public void init() {
> > resize(150,25);
> > }
> > public void paint(Graphics g) {
> > g.drawString("Hello world!", 50, 25);
> > }
> > }
> >
> > as you can see, the init method was called. This should work fine. the
> > resize funtion calls update which calls paint or does it call repaint
> > which calls paint, well no matter, paint() eventually gets called down
> > the line :)
>
> So I tried it and when I tried to compile it, I got
>
> ------- Start Compile Error -------
>
> hello_world.java, Line 2: Warning: Public class HelloWorld must be defined
> in a file called "HelloWorld.java".
> >> public class HelloWorld extends hava.applet.Applet {
> >> ^
>
> ------ End ------
>
> I thought that's what I was trying to do! Maybe I spent too much time as a
> English Major (like someone else in this newsgroup). I've never pl.ayed
> with object-orientated languages, by I wrote some mean Assembly on a
> Trash-80 back in HS, and can fake my way through Perl, so I'm not a
> complete idiot.
>
> ,,,-dave
> ---------------------------------------------------ooo0-(. .)-0ooo--------
> David | dave.solko@uc.edu 513-556-5264 (_)| Consultant
> E. | http://ucunix.san.uc.edu/~solkode/ |
> Solko | http://www.uc.edu/www/newsrecord/index.html | Webmaster
> --------------------------------------------------------------------------
> PGP Key fingerprint = 4D A7 1C 71 E5 4B C9 8E 33 CE 35 FA 17 86 50 84
> --------------------------------------------------------ooo0---0ooo----------
>
Fair dinkum David!
You English majors sure have trouble with comprehension. The compiler is
screaming the answer at you:
> hello_world.java, Line 2: Warning: Public class HelloWorld must be defined
^^^^^^^^^^^^^^^^
> in a file called "HelloWorld.java".
^^^^^^^^^^^^^^^
Why have you named the file `hello_world'? In order to find a class, the
compiler searches for a file of the same name. You therefore need to name the
file `HelloWorld.java' *not* `hello_world.java'.
In most OOPLs, a class equates to a file.
GREG
grege@optimation.com.au
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com