当前位置: 首页 > news >正文

个人做网站的时代已经过去门户网站建设不断

个人做网站的时代已经过去,门户网站建设不断,网站建设服务支持,黑龙省建设厅网站适用于非静态方法#xff1a;this.getClass().getName()适用于静态方法#xff1a;Thread.currentThread().getStackTrace()[1].getClassName()获取类名#xff1a;1、在类的实例中可使用this.getClass().getName();但在static method中不能使用该方法#xff1b;2、在stat…适用于非静态方法this.getClass().getName()适用于静态方法Thread.currentThread().getStackTrace()[1].getClassName()获取类名1、在类的实例中可使用this.getClass().getName();但在static method中不能使用该方法2、在static method中使用方法:Thread.currentThread().getStackTrace()[1].getClassName();获取方法名Thread.currentThread().getStackTrace()[1].getMethodName();获取代码行号Thread.currentThread().getStackTrace()[1].getLineNumber();Log 代码System.out.println(Class: this.getClass().getName() method: Thread.currentThread().getStackTrace()[1].getMethodName() line:Thread.currentThread().getStackTrace()[1].getLineNumber());http://blog.sina.com.cn/s/blog_4a4f9fb50101eyfp.htmlDescriptionBelow I present you two different ways to get the current Class:Using ThreadUsing getClass()getClass() method present in every Javaobject. Like here:String clazz  this.getClass().getName();static method. It wont work. Even the keyword this is meaningless in a static method.Also, the class returned by the above method may actually be a subclass of the class in which the method is defined. This is because subclasses inherit the methods of their parents; and getClass() returns the actual runtime type of the object. To get the actual class in which a method is defined, use the method below also.static method you can instead use the following:String clazz  Thread.currentThread().getStackTrace()[1].getClassName();Which uses the static methodgetStackTrace() to get the whole stacktrace. This method returns an array, where the first element (index 0) is the getStackTrace() you called and the second element (index 1) is the method your code is in.String method  Thread.currentThread().getStackTrace()[1].getMethodName();The codepackage org.wikijava.reflection;public class MethodName {   public static void main(String[] args) {MethodName methodName  new MethodName();String clazz  Thread.currentThread() .getStackTrace()[1].getClassName();String method  Thread.currentThread() .getStackTrace()[1].getMethodName();System.out.println(class name:   clazz   Method Name   method);methodName.anotherMethod(); }private void anotherMethod() {String clazz  this.getClass().getName();String method  Thread.currentThread() .getStackTrace()[1].getMethodName();System.out.println(class name:   clazz   Method Name   method);   }   }
http://www.huolong8.cn/news/309000/

相关文章:

  • 个人做网站开工作室网站添加百度搜索
  • wordpress 网站费用wordpress tag转专题
  • php网站开发意思苏州seo按天扣费
  • 网站排名优化查询在虚拟机做网站
  • 室内设计网站平面案例wordpress 判断首页
  • 手机端网站的区别电商网站支付接口
  • 一个ip 做2个网站吗河北建设工程信息网招聘网
  • 网站开发项目资金运用明细做微信平台网站
  • 甘肃网站建设开发超详细wordpress常用函数
  • 坪山住房及建设局网站湛江的网站建设公司
  • 网站建设案例代理商江苏企业seo推广
  • 长春网站建设索q479185700html5播放器
  • 空间链接制作网站鹤壁市做网站
  • 做企业网站多婚纱摄影网站设计
  • wordpress整站搬迁单页网站 html5 动态
  • 织梦新手网站建设学院网站建设方案 网站内容
  • 发布信息的网站平台企业采用劳务派遣方式用工的
  • 做网站的职员称呼什么做企业网站10万起步
  • 苏州塔维斯网站建设建设银行 网站用户变成个人用户
  • 全国信用网站一体化建设wordpress 慢的上天
  • 国外js特效网站高凡玉中国互联网协会
  • 自助提交网站怎么做网站流量统计
  • 济南网站推广效果想注册一个公司怎么注册
  • 建设银行手机银行网站用户名是什么原因全国做网站找哪家好
  • 做网站的详细教程网站后台代码
  • 中国网站建设中心做网站要学些什么条件
  • 建设管理部门网站查询免费软件下载网站有哪些
  • 拥有服务器后如何做网站做网站自己买服务器吗
  • 做网站个体户经营范围酒店都不建网站吗
  • 百度收录站长工具网站开发的实训周