내가 응용 프로그램을 개발 오전에 배열을 채우기 .. 만들기 및 간단한 방법
class Wheel {
private int size;
Wheel(int s) {
size = s;
}
void spin() {
System.out.print(size + " inch wheel spinning, ");
}
}
public class Bicycle {
public static void main(String[] args) {
Wheel[] wa = { new Wheel(15), new Wheel(17) };
for (Wheel w : wa)
w.spin();
}
}
하지만 어떻게 우리가 더 간단 측면에서
Wheel[] wa = { new Wheel(15), new Wheel(17) };
을 표현할 수 있음을 알려 주시기 바랍니다.
Java Collections API를 확인하십시오. 콜렉션은 배열보다 선호됩니다. 왜냐하면 콜렉션 (Set, List 등)이 더 쉽게 작업 할 수 있기 때문입니다. – rob