Java基本語法--格式化輸出資訊(小作業1)
阿新 • • 發佈:2021-01-04
- 格式化輸出資訊
package csdn;
import java.util.Date;
import java.util.Locale;
public class Homework1 {
public static void main(String[] args) {
var d = new Date();
System.out.printf(Locale.CHINA,"%1$tY年%1$tm月%1$td日 %1$tT%1$tA",d);
System.out.printf("%1$tY%1$tm%1$td%1$tH%1$tM%1$ts" ,d);
System.out.println();
System.out.println(d.getTime());
String name = "陳醋";
byte age =18;
double money = 8000.1546;
String addr ="河南省許昌市";
System.out.printf("姓名:%s,年齡:%d嵗,金額:%.1f元,家庭住址:%s。 \n",name ,age ,money,addr);
}
}
##輸出結果