Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Kotlin for Java Developers Is This Thing On? Seeing Clearly

Dear Ben , I am having a problem with the debugPrint in the App.kt file, where the programme is printing Card@5ca881b5

Instead of showing the Card Details such as its value and suit from GameModel.debugPrint(), I am getting :

Card@5ca881b5

By any chance do you know why this happens? Thank you!

Ben Deitch
Ben Deitch
Treehouse Teacher

Hey Goh! I'm not sure without being able to see the code. Can you share your Card class?

1 Answer

Goh, did you change your Card class to be a data class? A normal class in Kotlin will print just the Object reference (Card@5ca881b5). The data class will have a beter toString method and will print Object's properties. Cheers