Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
Last active January 30, 2018 00:28
Show Gist options
  • Save hohonuuli/82d5f225fc5bdec2696d7e873c35e7c9 to your computer and use it in GitHub Desktop.
Save hohonuuli/82d5f225fc5bdec2696d7e873c35e7c9 to your computer and use it in GitHub Desktop.
public class Sample1 {
// --- Native methods
public native int intMethod(int n);
public native boolean booleanMethod(boolean bool);
public native String stringMethod(String text);
public native int intArrayMethod(int[] intArray);
// --- Main method to test our native library
public static void main(String[] args) {
System.loadLibrary("Sample1");
Sample1 sample = new Sample1();
int square = sample.intMethod(5);
boolean bool = sample.booleanMethod(true);
String text = sample.stringMethod("java");
int sum = sample.intArrayMethod(new int[] {1, 1, 2, 3, 5, 8, 13});
System.out.println("intMethod: " + square);
System.out.println("booleanMethod: " + bool);
System.out.println("stringMethod: " + text);
System.out.println("intArrayMethod: " + sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment