Apart from the break
problem, the main problem here is how you initialize your StringBuffer
.
There is no constructor accepting a char
as an argument, but there is one accepting an int for the capacity.
And that is the one you use...
You should do:
word = new StringBuilder(); // not StringBuffer
// switch. Then:
word.append("ain");
(also note the use of StringBuilder
instead of StringBuffer
; the latter is useful only in the rare case where thread-safety is required)