Skip to content

Instantly share code, notes, and snippets.

@rajeevprasanna
Created January 19, 2014 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajeevprasanna/8502195 to your computer and use it in GitHub Desktop.
Save rajeevprasanna/8502195 to your computer and use it in GitHub Desktop.
constructor with args
package constructors.superConstructorWitArgs;
public class Animal {
Animal(String name) { }
}
package constructors.superConstructorWitArgs;
public class Horse extends Animal {
//TODO : Comment the constructor and check the error
Horse() {
//super(); // Problem! as super class doesn't have a default constructor
super("name"); // works
}
public static void main(String[] args){
Horse horse = new Horse();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment