indexentry.java

来自「Beginning Java 2, SDK 1.4 Edition Exerci」· Java 代码 · 共 28 行

JAVA
28
字号
// Class encapsulating an index to the IndexedPersons.bin file
// Each object stores a second name and the position in the file where
// the corresponding record can be found. i.e. the first record
// is at position 0, the second at position 1, the third at position 2, etc.
import java.io.Serializable;

public class IndexEntry implements Serializable {
  private String name;
  private int position;
  
  public IndexEntry(String name, int position) {
    this.name = name;
    this.position = position;
  }
  
  public String getName() {
    return name;
  }
  
  public int getPosition() {
    return position;
  }
  
  // Method to compare two IndexEntry objects
  public int compareTo(IndexEntry entry) {
    return name.compareTo(entry.name);
  }
}

⌨️ 快捷键说明

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