I have an generic array class that stores other objects. When I try to get the object values from the generic array it prints the insert objects classpath. How can I access the value?
public class Shop implements Initializable {
@FXML private TextField name;
@FXML private TextField quantity;
@FXML private TextArea list;
MyArrayList<Item> array = new MyArrayList<>();
@Override
public void initialize(URL location, ResourceBundle resources) {
}
@FXML
private void addItem() {
int q = Integer.parseInt(quantity.getText());
String n = name.getText();
Item item = new Item(n,q);
MyArrayList.getInstance().add(item);
System.out.println(MyArrayList.getInstance().getItem(0));
//Outputs sample.Item@1674184b instead of the value Banana.
}