StringBuffer capacity can be found with the help of capacity() method in java. capacity() function find current storage of characters. Return type of capacity() is integer. Use of String capacity() in java is shown below.
Example of StringBuffer capacity() in java, JSP
public class StringBufferCapacityExample { public static void main(String[] args) { StringBuffer sb = new StringBuffer("Java StringBuffer capacity"); System.out.println("Output :"+sb); int lg = sb.length(); int lng = sb.capacity(); System.out.println("length :"+lg); System.out.println("capacity :"+lng); } }
Output
Output :Java StringBuffer capacity
length :26
capacity :42
Tags: StringBuffer




Link to Us