0

While studying Java , I stuck with concept of java Method and Native Method.Both have some Difference.I don't understand clearly what they meant?. Please help me,Thank you.

Seki
  • 10,763
  • 6
  • 47
  • 68
Oomph Fortuity
  • 5,370
  • 10
  • 37
  • 86

2 Answers2

4

A Java method is generically a code block with a name that you can write using plain java.

public void method() {
    System.out.println("I'm a java method!");
}

A native method is a method that is linked to a native library. Native libraries are linked to a java program through JNI (Java Native Interface) or JNA (Java Native Access) and a native method looks like this:

public native void method();

It's just a declaration, because the method implementation is done in the native library.

BackSlash
  • 21,187
  • 21
  • 84
  • 132
1

By definition :

Native methods are Java methods that start in a language other than Java. Native methods can access system-specific functions and APIs that are not available directly in Java.

Whereas the Java methods are written specifically in Java as language.

BackSlash
  • 21,187
  • 21
  • 84
  • 132
Vineet Singla
  • 1,539
  • 1
  • 18
  • 32