Last active
January 30, 2018 00:28
-
-
Save hohonuuli/82d5f225fc5bdec2696d7e873c35e7c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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