The compareTo method. First you compare this.ticker which is a String, then if they are the same then you compare by the this.purchasePrice which is a double hashCode public int hashCode() The hashCode method using the Code-> Generate equals and hashCode with no changes Overrides: hashCode in class Object Returns: int Representing the hashCode compareTo public int compareTo(Stock another) The compareTo method not auto generated Compares first by ticker and if the tickers are the same secondarily compares by price Specified by: compareTo" in interface Comparable Parameters: another - the object to be compared. Returns: int Representing order Throws: IllegalArgumentException"- if another is null.
The compareTo method. First you compare this.ticker which is a String, then if they are the same then you compare by the this.purchasePrice which is a double
hashCode
public int hashCode()
The hashCode method using the Code-> Generate equals and hashCode with no changes
Overrides:
hashCode in class Object
Returns:
int Representing the hashCode
compareTo
public int compareTo(Stock another)
The compareTo method not auto generated Compares first by ticker and if the tickers are the same secondarily compares by price
Specified by:
compareTo" in interface Comparable<stock>
Parameters:
another - the object to be compared.
Returns:
int Representing order
Throws:
IllegalArgumentException"- if another is null.

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images









