Constructor use this and super Java -


There is a superclass in my name, whose producer is a constructor. I have a sub-section of the employee name with two constructors, I want within the sub-class that the constructor calls the second sub-class constructor and the superclass constructor. Consider the following:

  public class Human (name of protected string; Protected string alias; Public Human (String N, String S) {name = n; Nickname = s; }}  

and employee

  Public class employees extend human {int salary; Public Employee () {System.out.println ("Creating an Employee"); } Public employees (int pay) {this ()); Super ("Marcos", "Petov"); This.salary = salary; }}  

I think this can not work, but I want your opinion, is there no way to do this?

You can not call this and super Both. It's super or if the constructor does not mention anything in the first line of Java, then it will call super ()


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -