我对JAVA还是很陌生,希望有人可以帮助我解决这个问题。
我有一个包含对象的集合。每个对象都有一些元素,其中之一是String数组(信号)。
我的问题是,如何访问遍历数组(信号)的元素。我想将数组中的每个元素与一些枚举进行比较。
我尝试了以下代码,但是在我的if语句中无法识别“ returnsig”。
但是可能有更聪明的方法吗?
公共类SignalSearch {
public Signalsearch() {
for (SignalEntry item : signalCollection)
for(String returnsig : item.getSignal());
if(returnsig = someString)
公共类SignalEntry {
//My elements for objects
Date timestamp;
int index;
double open;
double close;
double high;
double low;
double volume;
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public double getOpen() {
return open;
}
public void setOpen(double open) {
this.open = open;
}
public double getClose() {
return close;
}
public void setClose(double close) {
this.close = close;
}
public double getHigh() {
return high;
}
public void setHigh(double high) {
this.high = high;
}
public double getLow() {
return low;
}
public void setLow(double low) {
this.low = low;
}
public double getVolume() {
return volume;
}
public void setVolume(double volume) {
this.volume = volume;
}
public String[] getSignal() {
return signal;
}
public void setSignal(String[] signal) {
this.signal = signal;
}
String[] signal = {"","","",""};
}