Java 找不到符号 - 方法哈希集
Java cannot find symbol - method hashset
我的 java 申请有问题,class 租金是从公司继承的。在业务中,我想从 class 租赁访问方法 getStartTime,尽管我得到错误找不到符号 - 方法 getStartTime。
有人可以帮我吗?
Class 公司:
// instance variables
private HashSet<Verhuur> verhuur;
/**
* Constructor for objects of class Bedrijf
*/
public Bedrijf()
{
// initialise instance variables
this.verhuur = new HashSet<Verhuur>();
}
/**
*
*/
public void add(Verhuur verhuur)
{
this.verhuur.add(verhuur);
}
/**
*
*/
public void getBegintijd()
{
System.out.println(verhuur.getBegintijd());
}
Class 出租
// instance variabelen
private String Begintijd;
private String Eindtijd;
private int GebruikteBrandstof;
private boolean Schade;
private Boot boot;
/**
* Constructor for objects of class Verhuur
*/
public Verhuur(String Begintijd, String Eindtijd, int GebruikteBrandstof, boolean Schade, Boot boot)
{
// intialiseer instance variabelen
this.Begintijd = Begintijd;
this.Eindtijd = Eindtijd;
this.GebruikteBrandstof = GebruikteBrandstof;
this.Schade = Schade;
this.boot = boot;
}
/**
Return de Begintijd
*/
public String getBegintijd()
{
return Begintijd;
}
/**
Return de Eindtijd
*/
public String getEindtijd()
{
return Begintijd;
}
/**
Return de GebruikteBrandstof
*/
public int getGebruikteBrandstof()
{
return GebruikteBrandstof;
}
/**
Return de begintijd
*/
public boolean getSchade()
{
return Schade;
}
verhuur
是一个 HashSet<Verhuur>
,因此为了调用 Verhuur
class 的 getBegintijd()
方法,您必须从 HashSet
.
例如,以下代码将为 Set
的迭代器返回的第一个元素调用 getBegintijd()
方法:
public void getBegintijd()
{
if (!verhuur.isEmpty())
System.out.println(verhuur.iterator().next().getBegintijd());
else
System.out.println("empty set");
}
我的 java 申请有问题,class 租金是从公司继承的。在业务中,我想从 class 租赁访问方法 getStartTime,尽管我得到错误找不到符号 - 方法 getStartTime。
有人可以帮我吗?
Class 公司:
// instance variables
private HashSet<Verhuur> verhuur;
/**
* Constructor for objects of class Bedrijf
*/
public Bedrijf()
{
// initialise instance variables
this.verhuur = new HashSet<Verhuur>();
}
/**
*
*/
public void add(Verhuur verhuur)
{
this.verhuur.add(verhuur);
}
/**
*
*/
public void getBegintijd()
{
System.out.println(verhuur.getBegintijd());
}
Class 出租
// instance variabelen
private String Begintijd;
private String Eindtijd;
private int GebruikteBrandstof;
private boolean Schade;
private Boot boot;
/**
* Constructor for objects of class Verhuur
*/
public Verhuur(String Begintijd, String Eindtijd, int GebruikteBrandstof, boolean Schade, Boot boot)
{
// intialiseer instance variabelen
this.Begintijd = Begintijd;
this.Eindtijd = Eindtijd;
this.GebruikteBrandstof = GebruikteBrandstof;
this.Schade = Schade;
this.boot = boot;
}
/**
Return de Begintijd
*/
public String getBegintijd()
{
return Begintijd;
}
/**
Return de Eindtijd
*/
public String getEindtijd()
{
return Begintijd;
}
/**
Return de GebruikteBrandstof
*/
public int getGebruikteBrandstof()
{
return GebruikteBrandstof;
}
/**
Return de begintijd
*/
public boolean getSchade()
{
return Schade;
}
verhuur
是一个 HashSet<Verhuur>
,因此为了调用 Verhuur
class 的 getBegintijd()
方法,您必须从 HashSet
.
例如,以下代码将为 Set
的迭代器返回的第一个元素调用 getBegintijd()
方法:
public void getBegintijd()
{
if (!verhuur.isEmpty())
System.out.println(verhuur.iterator().next().getBegintijd());
else
System.out.println("empty set");
}