Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package HW5;
  2. /**
  3. An item with a key and a value.
  4. */
  5. public class Item implements Comparable<Item>
  6. {
  7. private String key;
  8. private String value;
  9.  
  10. /**
  11. Constructs an Item object.
  12. @param k the key string
  13. @param v the value of the item
  14. */
  15. public Item(String k, String v)
  16. {
  17. key = k;
  18. value = v;
  19. }
  20.  
  21. /**
  22. Gets the key.
  23. @return the key
  24. */
  25. public String getKey()
  26. {
  27. return key;
  28. }
  29.  
  30. /**
  31. Gets the value.
  32. @return the value
  33. */
  34. public String getValue()
  35. {
  36. return value;
  37. }
  38.  
  39. public int compareTo(Item otherObject)
  40. {
  41. Item other = (Item) otherObject;
  42. return key.compareTo(other.key);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement