六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 116|回复: 0

常用傻瓜代码

[复制链接]

升级  9.33%

18

主题

18

主题

18

主题

秀才

Rank: 2

积分
64
 楼主| 发表于 2013-2-7 19:11:39 | 显示全部楼层 |阅读模式
一些老要用的代码,写下来,年纪大了,记不住,hoho
for (Iterator i = groups.iterator(); i.hasNext();) {     Group group = (Group) i.next();     System.out.println(group.get**());   }

2.String int 的互相转换
String test="1";int i=Integer.parseInt(test);int i=1;String test=Integer.toString(i);
http://hi.baidu.com/9prior/blog/item/41382b2535bc946535a80f3e.html

3.hidden
<input type="hidden" id="isok" value="true" />

4.时间问题
Date date=new Date();SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");sdf.format(date);

5.integer之间的比较
a.equals(new Integer(1))

6.遍历map
public SimpleOperationRepostitory(Map<String, Integer> initRepos) {this();for (Entry<String, Integer> e : initRepos.entrySet()) {repos.put(e.getKey(), BaseOperation.build(e.getValue(), e.getKey()));}}
7.switch用法
public boolean doAssert(Object value) {if (value instanceof String) {String str = (String) value;switch (option) {case ANCESTOR_OR_EQUAL:return str.startsWith(hierachyLimit);case ANCESTOR:return str.startsWith(hierachyLimit)&& str.length() > hierachyLimit.length();case DESCENDANT_OR_EQUAL:return hierachyLimit.startsWith(str);case DESCENDANT:return hierachyLimit.startsWith(str)&& hierachyLimit.length() > str.length();default:return false;}}return false;}
8.简单描写
return result > 0 ? true : false;
9.遍历
Set<String> permissions = new LinkedHashSet<String>();for (String roleName : roleNames) {}

10.类的声明
private static final long serialVersionUID = 1L;
11.log语句
private static final Logger logger = Logger.getLogger(VersionDBServiceImpl.class);logger.debug
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表