Login | Register   
LinkedIn
Google+
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: Intermediate
May 26, 2004

Generate a String of Specified Characters and of Desired Length

The following function generates a string of specified characters and of desired length:

public static String getStringOfChars(char ch,int length)
	{
		StringBuffer sb=new StringBuffer();
		
		sb.setLength(length);
		
		return sb.toString().replace('\u0000',ch);
	}
Srikanth Seshadri
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date