Java Keyword Native

The reserved keyword native is used in a method declaration to specify that a method is not implemented in the same Java source file. For example, you could define a method as native that was written in C programming and include it in Java program.

When a method is defined with the native keyword, you are basically just referencing the method name but no custom implementation. The mechanism used to integrate C method with your Java application is called the Java Native Interface (JNI).

//JavaCodeDepot Sample 

public class JavaCodeDepotNativeClass {
    public native void someMethodInC(String firstVariable, String secondVariable);

The complete list of Java reserved keywords contains a total of 50 keywords and 3 literal words that are unable to be used as variable names.

Add a Comment

Your email address will not be published. Required fields are marked *