Java: String.format

(Last Updated On: )

To format a string with parameters use String.format. There are different ways to use it depending on boolean, number, etc.

Format with Boolean

  1. String.format("Boolean: %b", true)

Format with Number

  1. String.format("Number: %n", 32)

Format with String

  1. String.format("String: %s", "Information")