Find the EnsureCapacity of the given StringBuffer object - Java Quiz Question


Write a program to find the EnsureCapacity of the given StringBuffer object.

Input (StringBuffer, Integer) Output (Integer)
'How are you', 28 56
'good morning', 29 58
'meritcampus school', 20 34



class StringBufferEnsureCapacity
{
    public static void main(String s[])
    {
        StringBuffer sb = new StringBuffer("How are you");
        int capacity = 28;
        System.out.println("The EnsureCapacity of the given StringBuffer object is : " + getEnsureCapacity(sb, capacity));

    }


    public static int getEnsureCapacity(StringBuffer input, int capacity) {
    }

}