hasNext() will return true it iteration has more values and next() returns the next element in iteration
List<string> listX = new List<String> {'A','B','C'}; Iterator<String> iter = listX.iterator(); while(iter.hasNext()) system.debug(iter.next());
The above code just grabs a single instance of your Iterator object and allows you to process the values. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm#apex_System_List_iterator
Plese let me know if it helps you. Best Regards, -Vivek
hasNext() will return true it iteration has more values and next() returns the next element in iteration
The above code just grabs a single instance of your Iterator object and allows you to process the values.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm#apex_System_List_iterator
Plese let me know if it helps you.
Best Regards,
-Vivek