In Java, the native keyword is used to declare a method which is implemented in platform-dependent code such as C or C++. When a method is marked as native, it cannot have a body and must ends with a semicolon instead. The Java Native Interface (JNI) specification governs rules and guidelines for implementing native methods, such as data type conversion between Java and the native application.

The following example shows a class with a method declared as native:

public class NativeExample {

	public native void fastCopyFile(String sourceFile, String destFile);

}

See all keywords in Java.

 

 

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.