Other Modifiers

A number of other modifiers are useful in defining methods. You can specify that a method should synchronize its resources, or that the method is for a native code implementation. These options are discussed next.

Native

Declaring a method as native means that you are giving the signature for a method that will be actually coded in another language, such as C. You can then call this code from a Java method. This feature is called the Java Native Interface, or JNI. This is a big topic that whole books cover, so this section will just point you to the basics.

Caution

This topic has a lot of potential "gotchas," so I recommend it only for experienced Java programmers.

Native methods are used when you really need to accomplish something ...

Get PURE Java™ 2 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.