I'm having trouble identifying what exactly this is. At this point, I am familiar with what methods, constructors, and class declarations look like. Which is this? Why does it look like a constructor and a method had a baby?
public Polygon polygonFrom(Point[] corners) {
// method body goes here
}
What you have is a method
why?
In Java, method declarations have five components, in order:
public, private, and others you will learn about later.void if the method does not return a value.(). If there are no parameters, you must use empty parentheses.public Polygon polygonFrom(Point[] corners) {
// method body goes here
}
Analyze your code snippet :
1. public is modifier
2. Polygon is return type
3. plygonForm is method name
4. (Point[] corners) is the parameter list in parenthesis
5. {} is a method body
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With