作者:lovely月夜静悄悄知_302 | 来源:互联网 | 2023-05-18 04:00
This question already has an answer here:
这个问题已经有了答案:
- Why does Java have transient fields? 13 answers
- 为什么Java有瞬变字段?13个答案
I have an issue related to the transient
keyword's use before the private
modifier in java .
我有一个问题与java中私有修饰符之前的瞬态关键字的使用有关。
variable declaration:
变量声明:
transient private ResourceBundle pageResourceBundle;
When I Googled it, I found these docs below, but they're talking about serialized. Actually my class does not implement any serialized.
当我在谷歌上搜索的时候,我发现了下面的这些文档,但是它们是序列化的。实际上,我的类没有实现任何序列化。
For More info:
更多信息:
http://java91.blogspot.in/2017/01/why-does-java-have-transient-fields.html
http://java91.blogspot.in/2017/01/why-does-java-have-transient-fields.html
My class looks like this :
我的班级看起来是这样的:
public class LoginViewModel extends AbstractViewModel {
transient private ResourceBundle pageResourceBundle;
@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
initializeLoginValues();
boolean timeout = BooleanUtils.toBoolean(getHttpServletRequest().getParameter("timeout"));
if (timeout) {
Messagebox.show(pageResourceBundle.getText("MSG_SESSION_HAS_EXPIRED_PLEASE_LOGIN"), pageResourceBundle.getText("LABEL_ALERT"),
Messagebox.OK, Messagebox.ERROR);
}
view.getPage().setTitle(CsdcLicence.get().getApplicationName());
}
I have some questions.
我有一些问题。
1.why use the transient
keyword before a private variable?
1。为什么在私有变量之前使用瞬态关键字?
2.what is the purpose of using this keyword?
2。使用这个关键字的目的是什么?
5 个解决方案