【发布时间】:2013-04-09 21:49:52
【问题描述】:
我有方法通过传递参数 ipadd 来调用 getSystem(),我有两个类,如下所述
SystemReport Class
public class SystemReport
{
protected System[] system;
public ComputerSystemResponse ()
{
}
public void setSystems( System[] system )
{
this.system = system;
}
public System[] getSystem()
{
return system;
}
}
我感兴趣的站点详细信息所在的系统类,
public class System
{
protected String site;
public System()
{
}
public System(String site)
{
this.site=site;
}
public void setSite(String site)
{
this.site = site;
}
public String getSite()
{
return site;
}
}
不同类中的方法&试图通过循环检索站点的值
SystemReport rep = classInstance.getNames(ipadd);
System[] test = rep.getSystem();
getNames 的返回类型
protected SystemReport getNames (ipadd)
{
SystemReport rep = new SystemReport();
return rep;
}
回答问题:
1. classInstance.getNames(ipadd) 的返回类型为 SystemReport
2. rep size > 0
现在我想从代表那里获取网站,我尝试通过 test.length is 0 检查长度。我错过了什么?
【问题讨论】:
-
有什么问题?你正在执行什么代码,你希望它做什么,它会做什么?
-
由此返回的内容:
classInstance.getNames(ipadd); -
需要看
getNames..怎么返回的SystemReport
标签: java arrays oop class object