1,native是方法修饰符。Native方法是由另外一种语言(如c/c++,FORTRAN,汇编)实现的本地方法。一般用于JNI中。
public class testdll
{
static
{
System.loadLibrary("test");
}
public native static int get();
public native static void set(int i);
public static void main(String[] args)
{
testdll test = new testdll();
test.set(10);
System.out.println(test.get());
}
}
2,transient
transient是一个变量修饰符,标记为transient的变量,在对一个对象进行序列化时,这些变量状态不会被序列化。
例如,假设某个类的成员变量是transient,那么当通过ObjectOutputStream把这个类的某个实例保存到磁盘上时,实际上transient变量的值是不会保存的。
当对象序列化的保存在存储器上时,不希望有些字段数据被保存,为了保证安全性,可以把这些字段声明为transient。
要更明白,可以看一些序列化的内容。