What is a transient variable? and what is the native keyword?

jwbecalm 2005-06-22 12:21:03
最近在看scjp的TIP。
有这几句话:
8.A transient variable may not be serialized.
9. The transient keyword is applicable to variables only.
10. The native keyword is applicable to methods only.


请问是什么意思?感觉以前看书没见到过。

...全文
108 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jwbecalm 2005-06-29
  • 打赏
  • 举报
回复
还是不大明白,自己再去查查资料。。
谢谢个位了。
wutongjoe 2005-06-23
  • 打赏
  • 举报
回复
Native methods are used when the implementation of a particular method is present in language other than Java say C,C++.
To use the native methods in java we use the keyword native
public native method_a()
This native keyword is signal to the java compiler that the implementation of this method is in a language other than java.
Native methods are used whenwere alize that it would take up a lot of rework to write that piece of already existing code in other language to java.
wutongjoe 2005-06-23
  • 打赏
  • 举报
回复
A transient variable is a variable that may not be serialized. If you don't want some field to be serialized, you can mark that field transient or static.
jwbecalm 2005-06-22
  • 打赏
  • 举报
回复
。。。。
翻译我知道,只是书上没见过,
能有点例子吗?
mofeir 2005-06-22
  • 打赏
  • 举报
回复
翻译成中文就是。
8.transient变量可以不是序列化的。//不过一般transient变量都是序列化的。
9.transient关键字只能形容变量。//呵呵,这个容易劣迹
10.native关键字字能形容方法。//这个也是。native一般就是去调用本地方法,难道还有本地变量?不可能

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧