Functions

A function is a block of code that has a name, a return type and a list of arguments. Every Java program has at least one function: main. Execution of a program starts with main. The function main usually makes calls to other functions. In this lesson you will learn to write your own functions, and call them. One use for functions is to break a program into separate functions to improve the readability of a program and to create functions that can be used in other programs. Each function should have a clearly defined purpose. Each function should also have a comment to explain its purpose.

Please study the material at each of the links below.

  1. A function half
  2. Function is after main
  3. A function to print area
  4. Arguments must match parameters
  5. Functions can call other functions
  6. A menu driven program
Like us on Facebook:


OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher: Zebra0.com
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: May 23 2017 17:41:24.