Formatting string in Java using return string.format(...) -
I want to return something like this: "The title book title , author book writer : $ cost "
There are bold variables I can not understand how this string is used to use the string. Format ("% s .., blah blah")
string title = "book title "; String author = "book author"; Double cost = 100; String text = string Format ("title% s, author% s: $% .2f", title, author, cost); Println (text); // print "title book title, author book author: $ 100.00" // or System.out.pritnf ("title% s, author% s: $% .2f", title, author, cost);
Comments
Post a Comment