Home > Java > javaTutorial > How to use transient in java

How to use transient in java

WBOY
Release: 2023-04-30 09:19:12
forward
1404 people have browsed it

1. Transient prevents variables modified with this keyword from being serialized. When the object is deserialized, the variable value modified by transient will not be persisted and restored.

2. Transient can only modify variables, but not classes and methods.

Example

public Catalog TreeCatalog(String catalogId) {
 
    Catalog catalogNode = findById(catalogId).get(); // 查询当前节点
 
    List<Catalog> catalogList = findChild(catalogId); //查询该节点的所有子节点
 
    for (Catalog child : catalogList) {
 
        Catalog catalog = TreeCatalog(child.getCatalog_id());
 
        catalogNode.getChildren().add(catalog);
 
    }
 
    return catalogNode;
 
}
Copy after login

The above is the detailed content of How to use transient in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template