I have an object called Product
and I want to check if a user-entered string matches the name of one of the Product
s.
I tried the code below but it doesn't work.
Product laptop = new Product(1, "Laptop", "Type", 1350.25, "black");
Product mouse = new Product(2, "Mouse", "Type", 50.50, "black");
String check = new String("laptop");
if (check.equals(instanceof Product))
{
System.out.println("Yes it is.");
}
else
{
System.out.println("No, it is not.");
}