Declaring a Method
Methods are truly the heart and soul of Java programs. They serve the same purpose in Java that functions do in C, C++, and Pascal—only the terminology is different. All execution that takes place in any application or applet takes place within a method. It is only by combining multiple dynamic methods that large-scale Java applications are written.
Like C++ functions, Java methods are the essence of each class and are responsible for managing all the tasks that can be performed. It is also true that methods exist only within classes in Java. There is no concept of a global function in Java that exists outside of a class.
Look at the parts of a method as shown in the following simple example:
void simpleMethod(){ System.out.println("Inside ...
Get Special Edition Using Java 2 Standard Edition 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.