实验内容和原理:
1、 将布尔型、整型、长整型、双精度型作为参数,实例化相应的包装类对象,并输出对象的数值。
2、 按照“XXXX年XX月XX日 XX时XX分XX秒”的格式,输出当前时间。
package xiejie;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class shili {
public static void main(String[] args) {
// TODO Auto-generated method stub
Boolean b1 = new Boolean(true);
boolean b2 = b1.booleanValue();
Integer i1 = new Integer(97);
int i2 = i1.intValue();
Double d1 = new Double(9.555);
double d2 = d1.doubleValue();
Long l1 = new Long(9597);
long l2 = l1.longValue();
System.out.println(b2);
System.out.println(i2);
System.out.println(d2);
System.out.println(l2);
SimpleDateFormat r = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
System.out.println(r.format(Calendar.getInstance().getTime()));
}
}