Chapter 4

Methods in Java

OBJECTIVES
  • To introduce Java method definition and method invocation
  • To implement Big2 application to understand methods
  • To explain passing primitive data types to methods with AreaFunction application
  • To generate prime numbers
  • To introduce the power of recursion with factorial function
  • To explain the pitfalls of recursion with Fibonacci function
  • To design overloaded methods
  • To explain method overloading with AdditionCalculator application
  • To illustrate passing one-dimensional arrays to methods using SortNumbers applications
  • To define sort() method with String array as an argument
  • To explain passing two-dimensional arrays to methods with Recipes application
4.1 INTRODUCTION

A method is a set of Java statements, ...

Get JAVA Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.