[5681] in java-interest
Re: [Mac] Constructor Problem
daemon@ATHENA.MIT.EDU (Greg Ewing)
Thu Feb 22 08:40:13 1996
Date: Thu, 22 Feb 1996 15:38:05 +1100
From: grege@optimation.com.au (Greg Ewing)
To: java-interest@java.sun.com
Cc: senelson@mediacity.com
> From NewsGroup_comp-lang-java Thu Feb 22 08:25 EST 1996
> From: NewsGroup_comp-lang-java
> >From: senelson@mediacity.com (Steve Nelson)
> Subject: [Mac] Constructor Problem
> Date: 21 Feb 1996 00:48:21 -0800
> Nntp-Posting-Host: handler.eng.sun.com
> To: java-interest@java
>
> Hi. I'm trying to get a short applet to compile on a Mac running the JDK
> 1.0 Beta (what else?) and am getting frustrating and bewildering error
> messages.
>
> Here's the error:
> StevesApplet.java: no constructor matching Jubal(int, int, int, int) found
> in class Jubal.
> >> theJubal = new Jubal(50, 50, 50, 50);
> >>
>
>
>
> Here's the code:
>
> import java.applet.Applet;
> import java.awt.*;
>
> class Jubal {
> int x;
> int y;
> int height;
> int width;
>
> public void Jubal(int newX, int newY, int newHeight, int newWidth) {
> x = newX;
> y = newY;
> height = newHeight;
> width = newWidth;
> }
>
> public void Jubal() {
> x = 50;
> y = 50;
> height = 50;
> width = 50;
> }
>
> void draw(Graphics theWindow) {
> theWindow.drawOval(x, y, height, width);
> }
> }
>
>
> public class StevesApplet extends Applet {
> Jubal theJubal;
>
> public void init() {
> resize(150, 150);
> theJubal = new Jubal(50, 50, 50, 50);
> }
>
> public void paint(Graphics theWindow) {
> theJubal.draw(theWindow);
> }
> }
>
> I can't say that I understand the error message, considering I've got a
> perfectly good constructor for Jubal(int, int, int, int). Sorry if this is
> a newbie mistake... Thanks!
>
>
> =SN
>
> Steve Nelson
> MediaCity HTML Design Staff Phone: (415) 854-9634
> senelson@mediacity.com Fax: (415) 854-4655
> ---------------------------------------------------------------------
>
>
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
>
Steve,
Your constructor is *almost* `perfectly good' except that you have a *void*
return type. A constructor has no return type. Therefore the compiler is
treating `Jubal(int, int, int, int)' as a normal routine, not a constructor.
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