There is no StringBuffer constructor that accepts a char. What happens here is that Java has made a widening primitive conversion to transform the char
into an int
and then a StringBuffer
with initial capacity of 77
was created.
But, there is a constructor that accepts a String
and you can use it to solve your problem:
StringBuffer buffer = new StringBuffer("M");
Anyway, it is also recommended that you use StringBuilder
, which is designed to be faster drop-in replacement for StringBuffer
in places where the string buffer was being used by a single thread.