I got this code:
System.out.println("Enter the brand and cash value");
String brand = keyboard.nextLine();
long cash = keyboard.nextDouble();
String buffer = keyboard.nextLine();
but even though I enter the exact String value I am trying to compare to, it fails to recognize they are the same. Strangely when I enter this:
compare[0] = new Car ("BMW", 12.00);
instead of this:
compare[0] = new Car (brand, 12.00);
it works
I also use equals:
public boolean equals(Car other)
{
if (other == null)
{
return false;
}
if(this.brand == other.brand && this.cash == other.cash)
{
return true;
}
else
{
return false;
}
}