![图片[1]-java中transient是什么-uusu优素-乐高,模型,3d打印,编程](https://uusu.cn/wp-content/uploads/2025/01/1634695858710599.png)
1、transient防止用这个关键词修饰的变量序列化。当对象被反序列化时,被 transient 修饰的变量值不会被持久化和恢复。
2、transient 只能修饰变量,不能修饰类和方法。
实例
publicCatalogTreeCatalog(StringcatalogId){
CatalogcatalogNode=findById(catalogId).get();//查询当前节点
List<Catalog>catalogList=findChild(catalogId);//查询该节点的所有子节点
for(Catalogchild:catalogList){
Catalogcatalog=TreeCatalog(child.getCatalog_id());
catalogNode.getChildren().add(catalog);
}
returncatalogNode;
}原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END


















































暂无评论内容