在交通灯的MainClass()中:
package com.isoftstone.interview.traffic;
public class MainClass {
public static void main(String[] args){
//S2N,S2W,E2W,E2S,N2S,N2E,W2E,W2N,S2E,E2N,N2W,W2S
String[] directions = new String[]{
"S2N","S2W","E2W","E2S","N2S","N2E","W2E","W2N","S2E","E2N","N2W","W2S"
};
for(int i = 0; i < directions.length; i++){
new Road(directions[i]);
}
new LampController();
}
}
请问for循环中建立了12个匿名Road对象是干什么用的?为什么匿名对象这样建立没有名字是怎么调用其中的方法的,请高手讲解一下,谢谢
|