关于List<String>和List<List<String>>的用法
有以下一段代码,看得不是很懂,望高人指点一下其中List<String>和List<List<String>>的具体运作过程:
是什么意思啊?为什么要用<>呢?
public DeviceInfo(List<String> tmp, List<List<String>> chanList)
{
this.deviceID = tmp.get(0);
this.stationInfo = InfoManager.getStationInfo(tmp.get(1));
this.phyRef = InfoManager.getPhysicalInfo(tmp.get(2));
FileTransform.newDir(this.stationInfo.orgPath + File.separator + this.deviceID);
this.epdPath = FileTransform.newDir(this.stationInfo.orgPath + File.separator + this.deviceID + File.separator + "epd");
this.ftpPath = FileTransform.newDir(this.stationInfo.orgPath + File.separator + this.deviceID + File.separator + "ftp");
this.orgPath = FileTransform.newDir(this.stationInfo.orgPath + File.separator + this.deviceID + File.separator + "org");
this.tmpPath = FileTransform.newDir(this.stationInfo.orgPath + File.separator + this.deviceID + File.separator + "tmp");
this.channels = new ArrayList<ChannelInfo>();
for (List<String> tmpList : chanList)
{
ChannelInfo chanInfo = new ChannelInfo(this, tmpList);
this.channels.add(chanInfo);
}
}
------解决方案--------------------
以前的List,好比是个箱子,你可以把相近的东西扔在里面
泛型好比是个收纳箱,不但可以放对象,还要在上面标明箱子里面放什么东西