r/javahelp • • Mar 05 '23

Solved Implementing a method within a toString method

I'm writing a class in which I have a class representing a circle. With the radius, two public methods were created to calculate the area and perimeter respectively. How might I call these methods in the toString method of the class? I have attached some of the class for visual representation.

Note: There is no good reason for you to down vote my posts.

0 Upvotes

10 comments sorted by

View all comments

2

u/AzurasTsar Mar 05 '23

You can override toString()... just declare a new method called toString() and have it return perimeter() + area() and whatever else (eg text etc) you might want

1

u/Charlemagne-767 Mar 05 '23

I will try that