That’s a great solution! However, I’d recommend a more structured approach using String.format()—it keeps things cleaner and easier to read, especially for formatted output.
@Override
public String toString() {
return String.format("Name: %s, Height: %.2f, Birthday: %04d-%02d-%02d",
name, height,
bDay.get(Calendar.YEAR),
bDay.get(Calendar.MONTH) + 1,
bDay.get(Calendar.DAY_OF_MONTH));
}
This ensures proper formatting, especially for height (%.2f for two decimal places) and date values (%04d for year, %02d for month/day). Much more readable!