O'Reilly logo

Programming with Java by Sunil Patekar, Mahesh Bhave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 6

FUNCTIONS

Every programming language supports functions in two categories: (1) user-defined functions, and (2) language-supplied functions (also known as library functions). To begin with, let us start with user-defined functions.

6.1 Functions in Java

In most object-oriented languages, either functions belong to a class or they do not belong to any particular class (free or global). In Java, every function must be a part of some class. There is no concept of free or global function.

Functions are small pieces of code doing a particular task. Functions are called methods in Java. Hence, the name of the topic should have been “methods in Java”.

So far, we have not introduced objects. Hence, you may not appreciate the significance of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required