Bifalgorithm post · Computer science one · Arrays of Strings

How can StringBuilder be used to format a name?

How can StringBuilder be used to format a name? (Computer science one · Arrays of Strings) — "String firstName = \"Tom\";\n\nString lastName = \"Waits\";\n\nSt…

Ideas in this flowchart

  • Build a formatted name with StringBuilder
  • Initialize firstName with "Tom".
  • Initialize lastName with "Waits".
  • Construct the formatted name.
  • Create a StringBuilder initialized with lastName.
  • Append ", ".
  • Append firstName.
  • Convert the StringBuilder to a String with toString().
  • Store the result in formattedName.
  • The StringBuilder class can also be used directly.
Feed/

How can StringBuilder be used to format a name?

No cover

Channel

Computer science one

1 page

"String firstName = \"Tom\";\n\nString lastName = \"Waits\";\n\nString formattedName = new StringBuilder(lastName)\n\n.append(\", \")\n\n.append(firstName)\n\n.toString();\n\nYou can also use the StringBuilder class yourself directly."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.