collections.hashset
Class Product
java.lang.Object
collections.hashset.Product
public class Product
- extends java.lang.Object
Demonstrates how to override the hashCode and equals
methods to test for equality.
- Author:
- Thomas Rowland
Constructor Summary |
Product(int _id,
java.lang.String _name,
java.lang.String _descr,
int _qty,
double _price)
|
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Product
public Product(int _id,
java.lang.String _name,
java.lang.String _descr,
int _qty,
double _price)
hashCode
public int hashCode()
- Overridden hashCode method. This method gets called first when
this object is being added or removed from the HashSet.
- Overrides:
hashCode
in class java.lang.Object
equals
public boolean equals(java.lang.Object o)
- Overridden equals method. This method gets called when
the hash codes from both objects being compared are equal.
- Overrides:
equals
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
getId
public int getId()
getName
public java.lang.String getName()
getDescr
public java.lang.String getDescr()
getQty
public int getQty()
getPriceEa
public double getPriceEa()
getPriceNet
public double getPriceNet()