假设我有一个对象 Airport ,其成员有 airportCode 和 airportCity ,如下所示:
function Airport(airportCode, airportCity) {
this.airportCode = airportCode;
this.airportCity = airportCity;
};
如何创建可以添加的对象数组 Airport。在 Java 中,这将像这样工作:
while(st.hasMoreTokens()) {
Airport a = new Airport();
a.airportCode = st.nextToken();
a.airportCity = st.nextToken();
airports.add(a);
}