Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Dec 20, 2005

Overloading a Constructor or Method

Overloading a constructor or a method so it takes an extra argument based upon some specific requirement can result in duplicate code. For instance, a project that contains a lot of modules may have a requirement from a module to take to extra argument. To avoid this, pass "null" to the overloaded constructor:

Class Test {
	Test(String mgs){
		
		Test("data",null); // will call the Test(String mgs, Locale locale)
	}
	Test(String mgs, Locale locale){
		
	}

}
MV Prem Kumar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap