112 Chapter 5 Optional specifier. The next part
112 Chapter 5 Optional specifier. The next part of a method signature is a list of any optional specifiers. The possible values for these specifiers are static, final, abstract, native, and synchronized. A native method is used for writing a Java method that maps to a method written in a different programming language, a topic not discussed in this book. The other specifiers are discussed in detail later. A method might not use any of these specifiers, or a method might use more than one of them. The order of the access specifiers and optional specifiers is arbitrary. For example, you can declare main() as: static public void main(String [] args) However, you will almost always see the access specifier appear first in a method signature because it is the preferred style among Java programmers. Return value. A method signature must contain a return value type. If the method does not return a value, void is used. Otherwise, the data type of the return value is specified. Possible values for the return value are one of the eight primitive data types or a reference. Note that this allows you to return anything you want from a method because every variable in Java is either one of the eight primitive data types or a reference to an object. Method name. The name of the method must appear directly after the return value. The method name can be any valid Java identifier. The Java naming convention calls for naming a method in mixed case, so the first letter will be lowercase and other terms in the method name will be capitalized. Examples of mixed case include main, toString, getDay, and setPreferredSize. A common exception to mixed case is a term that is an acronym. For example, the name accessURL would be preferred to accessUrl. Using mixed case for naming methods is not required. It is strictly a naming convention only. However, keep in mind that Java s naming convention is widely used and accepted. You should have a specific reason for not following this convention. Parameter list. Immediately following the method name must appear a set of parentheses that contain the parameter list of the method. When a method is invoked, data can be passed in by the caller of the method. This passed-in data is copied into the parameters. A parameter consists
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision mysql hosting services