编程知识 cdmana.com

java JavaBean

{collapse-item label="JavaBean" open}

JavaBean It's mainly used to transfer data , That is to combine a set of data into a JavaBean Easy to transmit . Besides ,JavaBean Can be easily IDE Tools to analyze , Generate code for reading and writing properties , It is mainly used in the visual design of graphical interface .

{/collapse-item} {collapse-item label=" enumeration JavaBean attribute "}

import java.beans.*;

// enumeration javabean attribute 
        //import java.beans.*;
        BeanInfo info=Introspector.getBeanInfo(demo5_2_3.class);
        // List all properties , And the corresponding reading and writing methods 
        for(PropertyDescriptor pd:info.getPropertyDescriptors()){
            System.out.println(pd.getName());
            System.out.println(" "+pd.getReadMethod());
            System.out.println(" "+pd.getWriteMethod());
        }

JavaBean It's a naming convention class, It passes through getter and setter To define properties ; Property is a general term , Is not Java Grammatical rules ; You can use IDE Quickly generate getter and setter; Use Introspector.getBeanInfo() You can get a list of properties .

{/collapse-item}

This article altogether 253 Number of words , Average reading time ≈ 1 minute

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[await]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/09/20210909125824175L.html

Tags java javabean
Scroll to Top