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 by strRusty_gal: wrong code

3 Years
Discussion Span
Last Post by strRusty_gal

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?

Votes + 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) {

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.