說我要回這樣的事: 「標題BOOKTITLE,作者BOOKAUTHOR:$ 成本」格式化字符串中使用Java返回的String.Format(...)
雞舍粗體是變量。 我無法弄清楚如何返回此使用的String.Format( 「%S ..,等等等等」)
說我要回這樣的事: 「標題BOOKTITLE,作者BOOKAUTHOR:$ 成本」格式化字符串中使用Java返回的String.Format(...)
雞舍粗體是變量。 我無法弄清楚如何返回此使用的String.Format( 「%S ..,等等等等」)
String fs;
fs = String.format("Title %t, Author %a: $%c", bookTitle, bookAuthor, cost);
System.out.println(fs);
http://download.oracle.com/javase/tutorial/java/data/strings.html
String title = "bookTitle";
String author = "bookAuthor";
double cost = 100;
String text = String.format("Title %s, Author %s: $%.2f", title, author, cost);
System.out.println(text); // prints "Title bookTitle, Author bookAuthor: $100.00"
// or System.out.pritnf("Title %s, Author %s: $%.2f", title, author, cost);
2串和精度2
浮法String.format("Title %s, Author %s: $%f.2", bookTitle, bookAuthor, cost);