12:42 pm - Tuesday September 25, 2018

StringBuilder Example Program for trimToSize()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
//Example program for Trim to size
/**
 * @author:candidjava.com
 * @description:used to reduce the empty space & storage size of Stringbuilder in java
 */
public class TrimToSize {
	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		sb.append("  Java String   builder trimToSize     ");
		sb.trimToSize();
		System.out.println("StringBuilder :" + sb);// used for print the output
	}
}


Output :
StringBuilder :Java Stringbuilder trimToSize

Filed in: Z-A All Java Codes

Comments are closed.