Jump to content

.tostring method question in Java


antony12

Recommended Posts

Hello and welcome!

So, I recently finished a fairly lengthy programme on inheritance. I was instructed to provide a function toString() { [native code] } function in each class. The issue is that I have methods like getArea and getPerimeter in my subclasses. In my function toString() { [native code] } function for this class, I want function toString() { [native code] } to execute and, for example, output the region of the object that function toString() { [native code] } is invoked on. I just don't understand the syntax... I assumed it would be:

"Area : " + this.getArea()

However, it returns an error. So, in my function toString() { [native code] } class, how would I refer to this *unknown* object?

Thank you very much!

Link to comment
Share on other sites

  • Duma locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...