首页 > Web开发 > 详细

commons.apache

时间:2016-02-19 12:21:06      阅读:174      评论:0      收藏:0      [点我收藏+]

1、ToStringBuilder

  1.               //对象及其属性一行显示  
  2.             System.out.println(ToStringBuilder.reflectionToString(u));  
  3.             System.out.println(ToStringBuilder.reflectionToString(u, ToStringStyle.DEFAULT_STYLE));  
  4.             //属性换行显示  
  5.             System.out.println(ToStringBuilder.reflectionToString(u, ToStringStyle.MULTI_LINE_STYLE));  
  6.             //不显示属性名,只显示属性值,在同一行显示  
  7.             System.out.println(ToStringBuilder.reflectionToString(u, ToStringStyle.NO_FIELD_NAMES_STYLE));  
  8.             //对象名称简写  
  9.             System.out.println(ToStringBuilder.reflectionToString(u, ToStringStyle.SHORT_PREFIX_STYLE));  
  10.             //只显示属性  
  11.             System.out.println(ToStringBuilder.reflectionToString(u, ToStringStyle.SIMPLE_STYLE));  



结果显示: 

test.User@141d683[name=zhengtian,age=25] 
test.User@141d683[name=zhengtian,age=25] 
test.User@141d683[ 
  name=zhengtian 
  age=25 

test.User@141d683[zhengtian,25] 
User[name=zhengtian,age=25] 
zhengtian,25

commons.apache

原文:http://www.cnblogs.com/YDDMAX/p/5200214.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!