stabilize record usage in requires, add examples

This commit is contained in:
dankeyy 2023-03-17 19:40:42 +02:00
parent 8e40725d25
commit 94f9c6712d
No known key found for this signature in database
GPG key ID: 9EBEF7DB1A70533D
4 changed files with 90 additions and 62 deletions

View file

@ -1,15 +1,39 @@
package javaSource;
import java.util.Arrays;
public class Demo {
static {
System.loadLibrary("interop");
}
public static native String sayHello(String num);
// public static native int[] mularr(int[] arr);
public static native int[] mulArrByScalar(int[] arr, int scalar);
public static native long factorial(long n);
public static void main(String[] args) {
System.out.println(sayHello("Brendan"));
// int[] arr = {10, 20, 30, 40};
// System.out.println(mularr(arr));
// string demo
System.out.println(sayHello("Brendan") + "\n");
// array demo
int[] arr = {10, 20, 30, 40};
int x = 3;
System.out.println("Array " + Arrays.toString(arr) +
" multipled by " + x +
" results in " + Arrays.toString(mulArrByScalar(arr, x)) +
"\n");
// number + panic demo
// This can be implemented more peacefully but for sake of demonstration-
// this will panic from the roc side if n is negative
// and in turn will throw a JVM RuntimeException
long n = -1;
System.out.println("Factorial of " + n + " is " + factorial(n) + "\n");
}
}