Hi Everyone,

Thanks for viewing this thread.

How do I do the code similar in Java? The syntax for the code below is C#.

    public class Child : Parent
    {
        public Child(String a, String b) : base(c)
        {

        }
    }

I would like to seek for your help on Java. I have found the similar way to add ": base(c)" behind the child overloaded constructor but it didn't work. Is there any thing I have to do for Java?

Thanks for the time.

Edited 2 Years Ago by strRusty_gal: wrong code

Is this what you mean?

class A {
  public A(int i) { ... // constructor
  ...
}

class B extends A {
  public B(int i) {
     super(i);  // calls superclass's constructor
  }
  ...
}

I guess line 7 chould be public B(int i, String a, String b) { so that it would imitate line 3 in the OP post?

Comments
Yeah man! you are right as well! thanks for the contribution!!

Thank you for all the contribution. I finally figured out with all your input. =)

public class Child extends Parent   {
      public Child(String a, String b, String c) {
          super(c);
      }
}

It is similar to JamesCherrill post but just to add String c in the child overloaded constructor so that the system can capture the value to the base contructor.

This question has already been answered. Start a new discussion instead.