What changes should i make in the below code so that it compiles & runs successfully :
Also i am looking forward to use only for-loop both normal and the enhanced for loop and not the while-loop to traverse through the list.
class x {
public static Iterator reverse(List list){
return list.iterator();
}
public static void main(
String [] args){
List list = new ArrayList();
list.add("1");list.add("2");list.add("3");
for(Object obj:reverse(list))
System.out.print(obj + " " );
}
}