Created
October 28, 2017 18:22
-
-
Save hohonuuli/a58d97fd98f8c25e303a15f32bd993e5 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
class Sample1 { | |
// --- Native methods | |
@native def intMethod(n: Int): Int | |
@native def booleanMethod(b: Boolean): Boolean | |
@native def stringMethod(s: String): String | |
@native def intArrayMethod(a: Array[Int]): Int | |
} | |
object Sample1 { | |
// --- Main method to test our native library | |
def main(args: Array[String]): Unit = { | |
System.loadLibrary("Sample1") | |
val sample = new Sample1 | |
val square = sample.intMethod(5) | |
val bool = sample.booleanMethod(true) | |
val text = sample.stringMethod("java") | |
val sum = sample.intArrayMethod(Array(1, 1, 2, 3, 5, 8, 13)) | |
println(s"intMethod: $square") | |
println(s"booleanMethod: $bool") | |
println(s"stringMethod: $text") | |
println(s"intArrayMethod: $sum") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment