package test;
/**
* 该类是为了演示JNI如何访问各种对象属性等
*/
public class Demo
{
//用于演示如何访问静态的基本类型属性
public static int COUNT = 8;
//演示对象型属性
private String msg;
private int[] counts;
public Demo()
{
this("缺省构造函数");
}
/**
* 演示如何访问构造器
*/
public Demo(String msg)
{
this.msg = msg;
this.counts = null;
}
public String getMessage()
{
return msg;
}
/**
* 该方法演示如何访问一个静态方法
*/
public static String getHelloWorld()
{
return "Hello world!";
}
/**
* 该方法演示参数的传入传出及中文字符的处理
*/
public String append(String str, int i)
{
return str + i;
}
/**
* 演示数组对象的访问
*/
public int[] getCounts()
{
return counts;
}
/**
* 演示如何构造一个数组对象
*/
public void setCounts(int[] counts)
{
this.counts = counts;
}
/**
* 演示异常的捕捉
*/
public void throwExcp()throws IllegalAccessException
{
throw new IllegalAccessException("exception occur.");
}
}
评论0