⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bandpk.java

📁 ejb20_src_relationships.rar
💻 JAVA
字号:
package examples.ejb20.relationships.bands;

public class BandPK implements java.io.Serializable 
{
  public String name;
  public String founder;

  private int hashCode = -1;

  public BandPK() {}

  public BandPK(String name, String founder) 
  {
    this.name = name;
    this.founder = founder;
  }

  public boolean equals(Object other) 
  {
    if (other == this) return true;

    if (!(other instanceof BandPK))
      return false;
    
    BandPK otherPK = (BandPK)other;

    if (otherPK.hashCode() == hashCode()) {
      return name.equals(otherPK.name) &&
        founder.equals(otherPK.founder);
    } else {
      return false;
    }
  }
  
  public int hashCode() {
    if (hashCode == -1) {
      hashCode = name.hashCode() ^ founder.hashCode();
    }

    return hashCode;
  }

  public String toString() {
    return "(" + name + ", " + founder + ")";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -