Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从bean中获取java中另一个类的值_Java - Fatal编程技术网

如何从bean中获取java中另一个类的值

如何从bean中获取java中另一个类的值,java,Java,我正在一个类中设置JavaBean的值。如何在另一个类中获得值,有人能举个例子吗 import java.util.ArrayList; public class HomeBean { String indexname=""; String lastvalue=""; String changepercentage=""; ArrayList aindexname=new ArrayList(); ArrayList alastname=new

我正在一个类中设置JavaBean的值。如何在另一个类中获得值,有人能举个例子吗

import java.util.ArrayList;

public class HomeBean {
    String indexname="";
    String lastvalue="";    
    String changepercentage="";
    ArrayList aindexname=new ArrayList();
    ArrayList alastname=new ArrayList();
    ArrayList alastpercentage=new ArrayList();
    public String getIndexname() {
        return indexname;

    }
    public void setIndexname(String indexname) {
        this.indexname = indexname;
        System.out.println("******index name is *****"+indexname);
        aindexname.add(indexname);

    }

    public String getLastvalue() {
        return lastvalue;
    }
    public void setLastvalue(String lastvalue) {
        this.lastvalue = lastvalue;
    }
    public String getChangepercentage() {
        return changepercentage;
    }
    public void setChangepercentage(String changepercentage) {
        this.changepercentage = changepercentage;
    }
    public ArrayList getArrayListIndexName()
    {
        for(int i=0;i<aindexname.size();i++)
        {
        System.out.println("####indexname is######"+aindexname.get(i).toString());
        }   

     return aindexname; 
    }

    public ArrayList getArrayListLastValue()
    {
     return alastname;

    }

    public ArrayList getArrayListChangePercentage()
    {

     return alastpercentage;    
    }




}
import java.util.ArrayList;
公共类HomeBean{
字符串indexname=“”;
字符串lastvalue=“”;
字符串changepercentage=“”;
ArrayList aindexname=新的ArrayList();
ArrayList alastname=新的ArrayList();
ArrayList alastpercentage=新的ArrayList();
公共字符串getIndexname(){
返回indexname;
}
public void setIndexname(字符串indexname){
this.indexname=indexname;
System.out.println(“******索引名为******”+索引名);
aindexname.add(indexname);
}
公共字符串getLastvalue(){
返回最后一个值;
}
公共void setLastvalue(字符串lastvalue){
this.lastvalue=lastvalue;
}
公共字符串getChangepercentage(){
回报率;
}
公共void setChangepercentage(字符串更改百分比){
this.changepercentage=changepercentage;
}
公共ArrayList GetArrayListineXName()
{
对于(int i=0;i 0)
{
对于(int i=0;i

你能更详细地解释一下你的问题吗。
 mport java.util.ArrayList;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DomTableParser
{

 ArrayList listTable=new ArrayList();
    public ArrayList parseXmlFile(String tableservicevalue){
        //get the factory
     Document doc;  
            StringtoDocument stdoc=new  StringtoDocument();
              doc=stdoc.getDocument(tableservicevalue);

              //System.out.println("Information of all employees");


                HomeBean bean=new HomeBean();
            Element docEle = doc.getDocumentElement();




            NodeList indexNode = docEle.getElementsByTagName("INDEX");
            if(indexNode != null && indexNode.getLength() > 0) 
            {
                for(int i = 0 ; i < indexNode.getLength();i++)
                {
                    Element homeElmnt = (Element)indexNode.item(i);

                     DomParserTableDataSet dataSet=new DomParserTableDataSet();
                       String indexName = homeElmnt.getAttribute("INDEX_NAME");
                        String lastValue=homeElmnt.getAttribute("LAST_VALUE");      
                        String changePercentage=homeElmnt.getAttribute("CHANGE_PERCENTAGE");
                        //String questgroupid=loginElmnt.getAttribute("ID");
                        bean.setIndexname(indexName);
                        bean.setLastvalue(lastValue);
                        bean.setChangepercentage(changePercentage);
                        bean.getArrayListIndexName();
                        dataSet.setIndexName(indexName);
                         dataSet.setLastValue(lastValue);
                         dataSet.setChangePercentage(changePercentage);
                          listTable.add(dataSet);



                }
            }


        return listTable;
    }




}