Question: I have 2 of the code I want this code written in the Netbenz editor with the output (Using the Java language) A List Example:

A List Example: 1. import java.util.*; 2. public class ListDemo 3. { 4. public static void main(String args[]) 5. { 6. List list = new ArrayList(); 7. list.add("one"); 8. list.add("second"); 9. list.add("3rd"); 10. list.add(new Integer(4)); 11. list.add(new Float(5.0f)); 12. list.add("second"); // duplicate is added 13. list.add(new Integer(4)); // duplicate is added 14. System.out.println(list); 15. } 16.} A Set Example: 1. import java.util.*; 2. public class Set Demo 3. { 5. 4. public static void main(String args[]) 6. Set set = new HashSet(); 7. set.add("one"); 8. set.add("second"); 9. set.add("3rd"); 10. set.add(new Integer(4)); 11. set.add(new Float(5.0F)); 12. set.add("second"); // duplicate is not added 13. set.add(new Integer(4)); // duplicate is not added 14. System.out.println(set); 15. } 16. }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
