Introduction to Methods
New Terminology
- Defensive programming
- A programming strategy that
assumes that something can go wrong, no matter how careful we are.
- Scope
- In programming, the extent
to which a variable or method is visible to users of that variable or
method.
- Subprogram, function, method
- A collection of statements
that can perform a specified task.
They are "invoked" during program execution and "return" to
the
point of invokation when finished.
Programming specific
structures and terms
- scope
- In Java, block scope is the
norm for all variables.
Scope defines the visibility of variables and their values
within
an application.
- method
- The specific name given to
Java subprograms
- value returning method
- A method that performs an
action and returns a value
- void method
- A method that performs an
action but does not return a value
- return statement
- The statement in java that
returns a value to the calling method
- return type
- The data type of the
returned value from a method
- void
- A special return data type
that means that nothing is returned from a method
- parameter (formal parameter)
- A set of locally defined
variables in a method which recieve values from the calling method
- argument (actual parameter)
- A set of values that is
passed from the calling method to the invoked method
- call by value
- A scheme of copying the
value in the calling method to the local variable in the invoked
method's parameters.
Class notes
- Problem solving - followup
from the lab on Thursday.
- Ways
of Thinking About Problems.ppt
- Methods
- Defininitions
- IntrotoMethods.ppt
- DistanceV2.java
- DistanceV3.java
- DistanceV4.java