常用Java片段

1. 字符串与整型的相互转换

  1. String a = String.valueOf(2);   //integer to numeric string  
  2. int i = Integer.parseInt(a); //numeric string to an int 

2,得到当前方法的名字

public class MethodName {
    private void IamAMethod(){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        System.out.println(methodName);   
    }
public static void main(String[] args) {
MethodName mName=new MethodName();
mName.IamAMethod();
}
}

3,

posted @ 2014-07-18 16:43  塔斯曼  阅读(116)  评论(0编辑  收藏  举报