I am trying to call a method within an if statement but I keep getting the following error.
incompatible types: java.lang.String cannot be converted to boolean
When you run the getName method it should check the barcode the user enters and if it matches, it will return a String.
This is the class and method I am doing the method call.
public class ItemTable
public String getName (Item x)
{
String name = null;
if (x.getBarcode ("00001"))
name = "Bread";
return name;
}
This is the method/class I am calling from.
public class Item
private String barcode;
public Item (String pBarcode)
{
barcode = pBarcode;
}
public String getBarcode (String barcode)
{
return barcode;
}