adding my solution for String buffer question