public class Main {
public static void main(String[] args) throws Exception {
// Sample data
String name = "John";
int age = 30;
String city = "New York";
// Format JSON string using String.format
String jsonString = String.format("{\"name\":\"%s\", \"age\":%d, \"city\":\"%s\"}", name, age, city);
// Print formatted JSON string
System.out.println(jsonString);
}
}
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme