method headers - Method Headers We summarize method...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Method Headers We summarize method headers, define the signature of a method, and discuss its use. This material is covered in more detail in the course text, Gries/Gries. A method declaration consists of a specification (as a comment), a method header , and a body. Here is a method declaration: /** = "x is in the range 1. .50". */ public boolean isLess(int x) { return x >= 1 & x <= 50; } Here is the format of the method header we use in this class for the three kinds of methods in Java, giving information about calls on each kind of method, with a few notes below: Kind of method Format of header A call on a method: procedure public void <name> ( <parameter-list> ) ; Is a statement. function public <return-type> <name> ( <parameter-list> ) Is an expression, which yields a value. constructor public <class-name> ( <parameter-list> ) Appears in a new-expression or as the first statement of a constructor. Notes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

method headers - Method Headers We summarize method...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online