Dultus
❔ Accessing variable from another class
Yes, that's correct. As you pointed out you're trying to access an empty instance.
If you're planning to do a list of customers, I'd introduce an Id to them and a list of customers. You can create the list for the entire class or as a static object so you can access it from anywhere.
Next, pick your customer from the list and then check the balance.
An option could be to make a temporary variable like selectedCustomer that you set the selected customer to so you don't have to constantly access the list and search for it.
21 replies