1、  将布尔型、整型、长整型、双精度型作为参数,实例化相应的包装类对象,并输出对象的数值。

代码:

public class aaa {
 public static void main(String[] args) {
  Boolean a = new Boolean(true);
  Integer b = new Integer("66");
  Long c = new Long("520");
  Double d = new Double("3.1415");
  System.out.println(a);
  System.out.println(b);
  System.out.println(c);
  System.out.println(d);
 }
}

运行结果:

2.按照“XXXX年XX月XX日  XX时XX分XX秒”的格式,输出当前时间。

代码:

import java.util.Calendar;
public class mytime2 {
public static void main(String[] args) {
Calendar ca1 = Calendar.getInstance();
System.out.print("当前系统时间:     ");
System.out.print(ca1.get(Calendar.YEAR)+"年");
System.out.print((ca1.get(Calendar.MARCH)+1)+"月");
System.out.print(ca1.get(Calendar.DATE)+"日  ");
System.out.print(ca1.get(Calendar.HOUR)+"时:");
System.out.print(ca1.get(Calendar.MINUTE)+"分:");
System.out.print(ca1.get(Calendar.SECOND)+"秒");
}
}

运行结果: