|
1 | 1 | import java.io.*;
|
2 | 2 |
|
3 | 3 | public class ApiTest {
|
4 |
| - static |
5 |
| - { |
6 |
| - System.loadLibrary("ApiTest"); |
7 |
| - } |
8 |
| - |
9 |
| - public static native void fprint(PrintWriter ps, String format, double x); |
10 |
| - |
11 |
| - public static native void nativeMainMethod(); |
12 |
| - |
13 |
| - public static void main(String[] args) { |
14 |
| - ApiTest.nativeMainMethod(); |
15 |
| - |
16 |
| - double price = 44.95; |
17 |
| - double tax = 7.75; |
18 |
| - double amountDue = price * (1 + tax / 100); |
19 |
| - PrintWriter out = new PrintWriter(System.out); |
20 |
| - /* This call will throw an exception--note the %% */ |
21 |
| - //ApiTest.fprint(out, "Amount due = %%8.2f\n", amountDue); |
22 |
| - //out.flush(); |
23 |
| - |
24 |
| - objectArrayTest(); |
25 |
| - } |
26 |
| - |
27 |
| - private static native int[][] initInt2DArray(int size); |
28 |
| - |
29 |
| - |
30 |
| - |
31 |
| -public static void objectArrayTest() { |
32 |
| -int[][] i2arr = initInt2DArray(3); |
33 |
| -for (int i = 0; i < 3; i++) { |
34 |
| -for (int j = 0; j < 3; j++) { |
35 |
| -System.out.print(" " + i2arr[i][j]); |
36 |
| -} |
37 |
| -System.out.println(); |
38 |
| -} |
39 |
| -} |
| 4 | + static { |
| 5 | + System.loadLibrary("ApiTest"); |
| 6 | + } |
| 7 | + |
| 8 | + public static native void fprint(PrintWriter ps, String format, double x); |
| 9 | + |
| 10 | + public static native void nativeMainMethod(); |
| 11 | + |
| 12 | + public static void main(String[] args) { |
| 13 | + ApiTest.nativeMainMethod(); |
| 14 | + |
| 15 | + double price = 44.95; |
| 16 | + double tax = 7.75; |
| 17 | + double amountDue = price * (1 + tax / 100); |
| 18 | + PrintWriter out = new PrintWriter(System.out); |
| 19 | + /* This call will throw an exception--note the %% */ |
| 20 | + //ApiTest.fprint(out, "Amount due = %%8.2f\n", amountDue); |
| 21 | + //out.flush(); |
| 22 | + |
| 23 | + objectArrayTest(); |
| 24 | + } |
| 25 | + |
| 26 | + private static native int[][] initInt2DArray(int size); |
| 27 | + |
| 28 | + public static void objectArrayTest() { |
| 29 | + int[][] i2arr = initInt2DArray(3); |
| 30 | + for (int i = 0; i < 3; i++) { |
| 31 | + for (int j = 0; j < 3; j++) { |
| 32 | + System.out.print(" " + i2arr[i][j]); |
| 33 | + } |
| 34 | + System.out.println(); |
| 35 | + } |
| 36 | + } |
40 | 37 |
|
41 | 38 | }
|
0 commit comments