I don't know what it means to get Objecto as a parameter.

Asked 2 years ago, Updated 2 years ago, 110 views

public int compareTo(Object o)

CircleTwo c = (CircleTwo) o;

Here, I don't know what the parameter Objecto in CompareTo points to.

And do you mean to convert (CircleTwo) o in the second line?Code with the constructor CircleTwo above.

java code coding

2022-09-22 17:59

1 Answers

It's not a good design from an object-oriented design perspective.

You should receive it in an abstracted type (or interface) of CircleTwo, not as an CircleTwo.

Objecto means you're going to get all types. Then the reason for the transform is to transform the object into a class where the method exists to invoke the method of the object.

If it was designed properly, it would have been possible to get it into CircleTwo's interface or abstract class and call it without transforming it.


2022-09-22 17:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.