码迷,mamicode.com
首页 > Web开发 > 详细

commons.apache

时间:2016-02-19 12:23:24      阅读:203      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!