Home > Archive > Java Help > January 2007 > Java help
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hello all,
I am very new to Java and I am trying to write simple program.
I try to make a class but it doesn't compile!
Can anyone please help.
Thanks in advance,
Hamid
public class Stone1
{
public int length;
public int width;
public Steen1(int l, int w)
{
lengte = l;
width = w;
}
public int getSurface()
{
return length * width;
}
}
class Stone2 extends Stone1
{
Stone2()
{
}
}
| |
|
| On Sun, 28 Jan 2007 11:44:53 +0100, Kiani wrote:
>Hello all,
>
>I am very new to Java and I am trying to write simple program.
>I try to make a class but it doesn't compile!
>Can anyone please help.
>
>Thanks in advance,
>Hamid
>
>public class Stone1
>{
> public int length;
> public int width;
>
> public Steen1(int l, int w)
Just there ^^^^! The constructor name must match the class name. Are
you bilingual? I think it must be quite difficult for bilingual
people to remember which language they are using for their classes
etc.
| |
|
| Thanks Liz,
But that is not the problem. That mistake was made when I wrote this mail.
In the original class the classname and the constuctorname are the same. The
first part (Stone1) compiles OK, but when I add the second constructor
(Stone2 extends Stone1) doesn't compile.
Thanks,
Hamid
"Liz" <liz@XXXXzylanid.demon.co.uk> schreef in bericht
news:2a0pr257fenuuvakr1jmr50i9tmq5nsg8j@
4ax.com...
> On Sun, 28 Jan 2007 11:44:53 +0100, Kiani wrote:
>
>
> Just there ^^^^! The constructor name must match the class name. Are
> you bilingual? I think it must be quite difficult for bilingual
> people to remember which language they are using for their classes
> etc.
>
| |
|
| On Sun, 28 Jan 2007 13:22:10 +0100, Kiani wrote:
>Thanks Liz,
>But that is not the problem. That mistake was made when I wrote this mail.
>In the original class the classname and the constuctorname are the same. The
>first part (Stone1) compiles OK, but when I add the second constructor
>(Stone2 extends Stone1) doesn't compile.
>
>Thanks,
>Hamid
OK. In that case, you need to make a "no args" constructor for
Stone1, or fill in the Stone2 constructor with something like
super(6, 4); // on the first line of the Stone2 constructor
or whatever.
The constructor of the subclass, without specific instructions to run
the given constructor of the superclass, is looking for a no-args
version.
| |
| Andrew Thompson 2007-01-28, 8:08 am |
| On Jan 28, 11:22 pm, "Kiani" <adsl588...@tiscali.nl> wrote:
...
> But that is not the problem.
The most immediate problem of this reply is top-posting.
Please place responses below the text you are replying to.
>..That mistake was made when I wrote this mail.
> In the original class the classname and the constuctorname are the same.
One reason why it is always a good idea to produce an
SSCCE*, then *copy/paste* that SSCCE to the group.
Otherwise, your time, and our bandwidth, might be
wasted trying to sort out what is *really* happening.
The same applies to inputs to a program, and the
output produced. *Always* copy/paste.
* <http://www.physci.org/codes/sscce>
Andrew T.
|
|
|
|
|