作家
登录

Java反射机制应用实践

作者: 来源: 2017-05-18 08:56:25 阅读 我要评论

public EgyptianMau(String name) { super(name); } 
  •     public EgyptianMau() { super(); } 
  •  
  • public class Mutt extends Dog { 
  •     public Mutt(String name) { super(name); } 
  •     public Mutt() { super(); } 
  •  
  • 膳绫擎的Pet类持续自Individual,Individual类的的实现稍微复杂一点,我们实现了Comparable接口,从新自定义潦攀类的比较规矩,如不雅不是很明白的话,也没有关系,我们已经将它抽象出来了,所以不睬解实现道理也没有关系。

    1. public class Individual implements Comparable<Individual> { 
    2.     private static long counter = 0; 
    3.     private final long id = counter++; 
    4.     private String name; // name is optional 
    5.  
    6.     public Individual(String name) { this.name = name; } 
    7.  
    8.     public Individual() {} 
    9.  
    10.     public String toString() { 
    11.         return getClass().getSimpleName() + (name == null ? "" : " " + name); 
    12.     } 
    13.  
    14.     public long id() { return id; } 
    15.  
    16.     public boolean equals(Object o) { 
    17.         return o instanceof Individual && id == ((Individual)o).id; 
    18.     } 
    19.  
    20.     public int hashCode() { 
    21.         int result = 17; 
    22.         if (name != null) { 
    23.             result = 37 * result + name.hashCode(); 
    24.         } 
    25.         result = 37 * result + (int

        推荐阅读

        Linux性能分析工具汇总合集

      常见用法: netstat &ndash;npl 可以查看你要打开的端口是否已经打开。 netstat &ndash;rn 打印路由表信息。 netstat &ndash;in 供给体系上的接口信息,打印每个接口的MTU,输入分>>>详细阅读


      本文标题:Java反射机制应用实践

      地址:http://www.17bianji.com/lsqh/35285.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)