9:14 am - Wednesday December 19, 2018

StringBuilder Example Program for capacity()

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
/**
Author :candidjava.com
Description: To calculate the current capacity of the string by using  capacity() method it returns the current capacity of the String
*/
import java.io.*;
import java.lang.*;
public class CapacityExample
{
public static void main(String args[])throws IOException
{
String s="welcome";
StringBuilder sb=new StringBuilder(s);
int a=sb.capacity();//to calculate the current capacity of the string
System.out.println(sb);
System.out.println(?current capacity is?+a);
}
}

Output

welcome
23

BACK

Filed in: Z-A All Java Codes

Comments are closed.