void ff() {
  System.err.println(this.method.name());
  System.err.println(this.getName());
}

解决方案 »

  1.   

    sorry, i do a test, should be:
    System.out.println(this.getClass().getName());
      

  2.   

    import java.io.*;
    import java.util.*;  public void test(){
       System.out.println("Current method: " + getCurrentMethodName());
      }
      public String getCurrentMethodName() {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PrintWriter pw = new PrintWriter(baos);
          (new Throwable()).printStackTrace(pw);
          pw.flush();
          String stackTrace = baos.toString();
          pw.close();      StringTokenizer tok = new StringTokenizer(stackTrace, "\n");
          String l = tok.nextToken(); // 'java.lang.Throwable'
          l = tok.nextToken(); // 'at ...getCurrentMethodName'
          l = tok.nextToken(); // 'at ...<caller to getCurrentRoutine>'
          // Parse line 3
          tok = new StringTokenizer(l.trim(), " <(");
          String t = tok.nextToken(); // 'at'
          t = tok.nextToken(); // '...<caller to getCurrentRoutine>'
          return t;
      }
      

  3.   

    this.getClass().getName()是类名
    getCurrentMethodName()得到的是方法名
      

  4.   

    this.getClass().getMethods()[1].getName()
    好像只能得到类中所有方法的一个数组啊
      

  5.   

    this.getClass().getName();  // 得到包括 包名在内的类名this.getClass().getMethods()[0].getName();// 得到当前的方法名