Undefined constructor for the super class.

Discussion in 'Java' started by TheTravellingSalesman, Sep 3, 2007.

  1. 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
     
    TheTravellingSalesman, Sep 3, 2007
    #1
    1. Advertising

  2. TheTravellingSalesman wrote:
    > 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
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Sep 3, 2007
    #2
    1. Advertising

  3. TheTravellingSalesman

    SadRed Guest

    On Sep 3, 11:10 am, TheTravellingSalesman <>
    wrote:
    > 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.
     
    SadRed, Sep 3, 2007
    #3
  4. 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 2, 10:39 pm, SadRed <> wrote:
    > On Sep 3, 11:10 am, TheTravellingSalesman <>
    > wrote:
    >
    >
    >
    > > 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.
     
    TheTravellingSalesman, Sep 3, 2007
    #4
  5. 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 <>
    wrote:
    > 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 2, 10:39 pm, SadRed <> wrote:
    >
    > > On Sep 3, 11:10 am, TheTravellingSalesman <>
    > > wrote:

    >
    > > > 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.
     
    TheTravellingSalesman, Sep 3, 2007
    #5
  6. TheTravellingSalesman

    Lew Guest

    TheTravellingSalesman wrote:
    > 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.

    --
    Lew
     
    Lew, Sep 3, 2007
    #6
  7. TheTravellingSalesman

    GArlington Guest

    On 3 Sep, 06:30, TheTravellingSalesman <> wrote:
    > 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 <>
    > wrote:
    >
    > > 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 2, 10:39 pm, SadRed <> wrote:

    >
    > > > On Sep 3, 11:10 am, TheTravellingSalesman <>
    > > > wrote:

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


    Did you manage to override String class somewhere? Defined it
    yourself???
     
    GArlington, Sep 3, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,800
    Darryl Pierce
    Feb 24, 2005
  2. Fernando Rodriguez

    Getting the super class via the super() function

    Fernando Rodriguez, Nov 21, 2003, in forum: Python
    Replies:
    2
    Views:
    724
    Bob Willan
    Nov 22, 2003
  3. Kerim Borchaev

    super. could there be a simpler super?

    Kerim Borchaev, Jan 15, 2004, in forum: Python
    Replies:
    4
    Views:
    479
    Michele Simionato
    Jan 15, 2004
  4. fi3nd
    Replies:
    0
    Views:
    385
    fi3nd
    Apr 8, 2010
  5. Matthew Braid

    $class::SUPER as well as $instance::SUPER?

    Matthew Braid, Aug 6, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    309
    Matthew Braid
    Aug 9, 2004
Loading...

Share This Page