What is the native keyword in Java for?
问题 While playing this puzzle (It's a Java keyword trivia game), I came across the native keyword. What is the native keyword in Java used for? 回答1: The native keyword is applied to a method to indicate that the method is implemented in native code using JNI (Java Native Interface). 回答2: Minimal runnable example Main.java public class Main { public native int square(int i); public static void main(String[] args) { System.loadLibrary("Main"); System.out.println(new Main().square(2)); } } Main.c