Skip to content

Instantly share code, notes, and snippets.

@smamran
Created September 20, 2015 16:20
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 smamran/a2d8fceab0c49b3a8128 to your computer and use it in GitHub Desktop.
Save smamran/a2d8fceab0c49b3a8128 to your computer and use it in GitHub Desktop.
Java Default Constructor vs Parameterised Constructor
class Main {
public static void main(String[] args) {
Person person = new Person(); // will get error as defautl empty constructor is not given
}
}
class Person {
String firstName;
String lastName;
int age;
public Person(String f, String l, int a) {
firstName = f;
lastName = l;
age = a;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment