Friday, February 27, 2015

Example of Calling one constructor from another in Java

Instead of calling the constructor with the class name, use the keyword this.
public Contract() {
//some stuff here
}

public Contract(Integer salesid) {
this();
this.id = salesid;
}

Popular Posts

Labels

ad ( 3 ) Amazon ( 47 ) Answer ( 1 ) API ( 22 ) automation ( 1 ) blog ( 21 ) book ( 2 ) career ( 12 ) cdn ( 2 ) centos ( 1 ) cloud ( 116 ) CRM ( 20 ) current ( 9 ) data ( 14 ) database ( 61 ) design patterns ( 14 ) development ( 3 ) eCommerce ( 23 ) email ( 92 ) ETL ( 2 ) framework ( 3 ) git ( 7 ) google ( 176 ) IDE ( 10 ) Integration ( 1 ) interview ( 15 ) Java ( 358 ) Java EE ( 99 ) javascript ( 39 ) Jboss ( 4 ) JPA ( 48 ) JSF ( 44 ) linux ( 315 ) Marketing ( 18 ) mobile ( 42 ) model ( 1 ) MySQL ( 191 ) online money ( 11 ) OOP ( 7 ) open source ( 26 ) performance ( 70 ) php ( 46 ) python ( 47 ) quality ( 5 ) referral ( 3 ) restful ( 22 ) security ( 126 ) SEO ( 17 ) social ( 26 ) software ( 72 ) spam ( 4 ) Spring ( 1 ) SQL ( 22 ) system ( 29 ) testing ( 14 ) tool ( 73 ) UML ( 8 ) virtual ( 10 ) web ( 216 ) web services ( 13 ) WildFly ( 3 ) wordpress ( 7 )