posts - 75,comments - 83,trackbacks - 0
 System.out.format("%b\n",new Date());

对于b(布尔类型)来说:

如果是字符,字符串,数字,对象为true;

如果是NULL,则为FALSE



  System.out.format("%c\n",new Integer(50));

对于字符类型来说:

只能是:byte, int, short,字符,对应的包装类

其他的则报告错误

 


  System.out.printf("%d\n",new Long("99"));

对于整型数据来说:

如下:byte short int long 及其包装类都可以 但float double 不可以

 


  System.out.printf("%f\n",123.00);

对于浮点类型来说:必须是float 或者是 double   ,其他都不可以

 


  System.out.format("%s",'p');

对于字符来说:字符串,数字,对象都可以。其实就是用字符串描述参量

 

posted on 2009-03-02 22:00 梓枫 阅读(219) 评论(1)  编辑  收藏 所属分类: java

FeedBack:
# re: -------------格式化输出-------------
2009-03-07 11:06 | 格式化输出
又学一招  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: