java - Is this a class, constructor, or method? -


this question has answer here:

i'm having trouble identifying is. @ point, familiar methods, constructors, , class declarations like. this? why constructor , method had baby?

public polygon polygonfrom(point[] corners) {   // method body goes here } 

what have method

why?

in java, method declarations have 5 components, in order:

  1. modifiers—such public, private, , others learn later.
  2. the return type—the data type of value returned method, or void if method not return value.
  3. the method name—the rules field names apply method names well, convention little different.
  4. the parameter list in parenthesis—a comma-delimited list of input parameters, preceded data types, enclosed parentheses, (). if there no parameters, must use empty parentheses.
  5. the method body, enclosed between braces—the method's code, including declaration of local variables, goes here.
public polygon polygonfrom(point[] corners) {   // method body goes here } 

analyze code snippet :

1. public modifier

2. polygon return type

3. plygonform method name

4. (point[] corners) parameter list in parenthesis

5. {} method body


Popular posts from this blog