Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Undefined constructor for the super class.

Thread view: 
TheTravellingSalesman - 03 Sep 2007 03:10 GMT
I'm using eclipse to write my java program.

I am writing a class call it Node2 which extends Node1

The only difference is that Node1 has a constructor that take (double,
String, double) as parameters and it works absolutely fine <-- as I
tested node1.

However, when writing the node2's constructor, I have the following

=====================================================================

//The only difference between the two nodes is that Node 2 take an
additional vector as input.

public Node2 (double a1, String a2, double a3, Vector otherNodes)
    { super(a1,a2,a3);
     this.nextNodes = otherNodes;
       }
// the problem comes in line where I'm calling super because the
compiler (eclipse 3.2.2.) does not recognize super constructor of
node1.it says that the

"constructor (double, String, double) is undefined".

======================================================================

Any idea what I'm doing wrong or why would something like this
happen?

Any help is appreciated
Arne Vajhøj - 03 Sep 2007 03:38 GMT
> I am writing a class call it Node2 which extends Node1
>
[quoted text clipped - 3 lines]
>
> However, when writing the node2's constructor, I have the following

> //The only difference between the two nodes is that Node 2 take an
> additional vector as input.
[quoted text clipped - 13 lines]
> Any idea what I'm doing wrong or why would something like this
> happen?

May we see class declaration and all constructors for both classes ?

Arne
SadRed - 03 Sep 2007 03:39 GMT
On Sep 3, 11:10 am, TheTravellingSalesman <saad.za...@gmail.com>
wrote:
> I'm using eclipse to write my java program.
>
[quoted text clipped - 27 lines]
>
> Any help is appreciated

It should compile normally if your code is properly written.
We may need to see a small example code that shows the problem.
TheTravellingSalesman - 03 Sep 2007 03:50 GMT
Here's the constructor for Node1

public Node1(double a, String b, double c)
{
     this.nodePot = a;
       this.Name = b;
       this.rate = c;
}

And for the class for "Node2 extends Node1"

I have two Nodes which are extending Node1. While one of them works,
this one (i.e. Node2) doesn't work and I have no idea why. Same line
of code. I'm running them in the same project. Unless, I'm forgetting
to import something. If any of you guys want to see the exact lines of
entire classes, I can email them........although I've posted the
constructor above with the changed variable names......

> On Sep 3, 11:10 am, TheTravellingSalesman <saad.za...@gmail.com>
> wrote:
[quoted text clipped - 33 lines]
> It should compile normally if your code is properly written.
> We may need to see a small example code that shows the problem.
TheTravellingSalesman - 03 Sep 2007 06:30 GMT
It is usually the String class that gives me trouble. For instance, in
the contructors, where I'm using string, it says, the consturctor is
not same. Some places its giving me errors  like  "+=" operator is
undefined for type String..

even thought I have imported java.lang.*; its still giving me the
problems. ANy suggestions/ideas. Could it be my compiler or something
I haven't installed/added in?

On Sep 2, 10:50 pm, TheTravellingSalesman <saad.za...@gmail.com>
wrote:
> Here's the constructor for Node1
>
[quoted text clipped - 52 lines]
> > It should compile normally if your code is properly written.
> > We may need to see a small example code that shows the problem.
Lew - 03 Sep 2007 08:03 GMT
> It is usually the String class that gives me trouble. For instance, in
> the contructors, where I'm using string, it says, the consturctor is
> not same. Some places its giving me errors  like  "+=" operator is
> undefined for type String..

Which is strange, since that operator is defined for type String.

> even thought I have imported java.lang.*; its still giving me the

You never need to import java.lang.*.  The language imports that for you
regardless.

> problems. ANy suggestions/ideas. Could it be my compiler or something
> I haven't installed/added in?

People have suggested that you post an example.  Until you do, we're helpless
to help.

The example should be complete.  The fragmentary approach leaves out the part
of the code that has the problem.

Signature

Lew

GArlington - 03 Sep 2007 15:10 GMT
> It is usually the String class that gives me trouble. For instance, in
> the contructors, where I'm using string, it says, the consturctor is
[quoted text clipped - 64 lines]
> > > It should compile normally if your code is properly written.
> > > We may need to see a small example code that shows the problem.

Did you manage to override String class somewhere? Defined it
yourself???


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.