nativeexample.java

来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 28 行

JAVA
28
字号
/** A class that uses a native method
  * This class is assigned to the default package
  */
   public class NativeExample {
   /** the method increment is a wrapper for a C
     * function that resides in NativeExample.dll
     * @param input an int value that the C 
     *    function increments
     */
   public static native int increment( int input );

   /** test main method passes the value 4
     * to the native method and prints incremented
     * value returned by the native method
     * @param args not used
     */ 
   public static void main( String[] args ) {
      System.out.println( increment( 4 ) );
      System.out.println( 
         "Native method called successfully" );
   }

   static {  // static initialization block
      System.loadLibrary ( "NativeExample" );
      System.out.println ( 
         "Library Loaded Successfully" );
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?