I have the following enhanced for loop and I don't understand how it works. Can someone explain this particular example to me?
@Path("vm")
public class VmResource {
@GET
@Produces("application/json")
public List<HostDetail> getVms() {
VirtualBoxManager manager = VirtualBoxManager.createInstance(null);
List<HostDetail> machineValues = new ArrayList<HostDetail>();
for (String hostUri : PropertiesBean.getInstance().getServices()) {
try {
manager.connect(hostUri, PropertiesBean.getInstance().getUsername(), PropertiesBean.getInstance().getPassword());
IVirtualBox vbox = manager.getVBox();
IHost host = vbox.getHost();
URL url = null;
try {
url = new URL(hostUri);
} catch (MalformedURLException ex) {
Logger.getLogger(VmResource.class.getName()).log(Level.SEVERE, null, ex);
}
HostDetail hostDetail = createHostDetail(host, url.toString(),
vbox.getVersion(), url.getHost());
for (IMachine machine : vbox.getMachines()) {
hostDetail.getVirtualMachines().add(createMachineDetail(machine));
}
machineValues.add(hostDetail);
} catch (Exception ex) {
} finally {
manager.disconnect();
}
}
return machineValues;
}