2011-09-02 107 views

回答

6
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串和精度2

浮法
String.format("Title %s, Author %s: $%f.2", bookTitle, bookAuthor, cost); 
相關問題