Undefined constructor for the super class.

  • Thread starter TheTravellingSalesman
  • Start date
T

TheTravellingSalesman

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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

TheTravellingSalesman said:
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?

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

Arne
 
S

SadRed

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

It should compile normally if your code is properly written.
We may need to see a small example code that shows the problem.
 
T

TheTravellingSalesman

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......
 
T

TheTravellingSalesman

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?
 
L

Lew

TheTravellingSalesman said:
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.
 
G

GArlington

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?

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top