0

[JAVA] Change where toString appears in console

I have two classes, one is a Customer class and stores attributes and a toString. The other, my main class, has an object for the customer and when invoked the toString appears as the last statement executed. I have another object which needs to go before the toString from the Customer class is called. How can I change where the toString appears? To invoke the object I am using: System.out.println(customerObject()):

12th Aug 2019, 8:11 AM
Raj Grewal
Raj Grewal - avatar
1 Answer
+ 1
I cant be sure what you mean without seeing the code, in java each class inherits the toString() method from class Object there might be a problem with how your overriding this method if your classes extend from one another.
12th Aug 2019, 9:32 AM
D_Stark
D_Stark - avatar