Reputation: 197
I saw a line of code where I don't know what the signature of that method looks like. I've searched online for some examples and an explanation, but didn't find one.
The line of code:
Circle sum = Circle.add(new Circle(), new Circle());
I was wondering how the signature of the add method would look like with the 'new Circle()' as parameter.
Upvotes: 0
Views: 63
Reputation: 3914
Without knowing this API, you can use the following hints:
Circle
and returns an object of type Circle
. Circle.add(...)
, so it must be a static
method So the signature for this method will look something like:
public static Circle add(Circle c1, Circle c2);
or
public static Circle add(Circle... circles);
(the access modifier of the method can be other than public
)
Upvotes: 4
Reputation: 59986
Because it take same Object Circle
Object, i also suggest it can take an array
of Circle
and return a Circle
Object in the end like this :
public class Circle{
public Circle() {
}
public static Circle add(Circle...circles){
Circle c = ...;
//do soemthing
return c;
}
}
Or simply your class conscructor can take two Circle
like this :
public class Circle{
public static Circle add(Circle c1, Circle c2){
Circle c = ...;
//do soemthing
return c;
}
}
Upvotes: 1
Reputation: 12440
Signature is possibly:
add(Circle, Circle)
new Circle()
is no-params constructor call.
Upvotes: 1