How to avoid printing Memory address of variables in Java?
I can't understand why console printing Memory address instead of carList. https://code.sololearn.com/ca2179a13a10
Well you're printing the carList object itself, not it's contents. You have to iterate through each element carList is storing. Haven't touched Java in years so I'm not sure what the best approach would be for an arraylist object but i assume there's something like forEach(lambda)
Ok, thanks for 「ＨＡＰＰＹ ＴＯ ＨＥＬＰ」 and Nikhil. Now I understood.
You can also override the toString() method since it is invoked whenever you print an object. https://code.sololearn.com/caXPs3RVc8RY/?ref=app