COP3337_9 - The Java Collections Framework(I Dr Antonio L...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 The Java Collections Framework (I) Dr. Antonio L. Bajuelos Note: The most of the information of these slides was extracted and adapted from Horstmann’s book, “Big Java. Early Objects”, 5 th edition. They are provided for COP-3337 students only. Not to be published or publicly distributed without permission by the publisher. 2 Java Collections Frameworks: an overview ° When you need to organize multiple objects in your program, you can place them into a collection . ° The ArrayList cla ss that was introduced previously is one of many collection classes that the standard Java library supplies. ° A hierarchy of interface types and classes for collecting objects in Java . ° At the root of the hierarchy is the Collection inte rface. That interface has methods for adding and removing elements, and so on.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 3 Java Collections Frameworks: an overview ° When you need to organize multiple objects in your program, you can place them into a collection . ° The ArrayList cla ss that was introduced previously is one of many collection classes that the standard Java library supplies. ° A hierarchy of interface types and classes for collecting objects in Java . ° At the root of the hierarchy is the Collection inte rface. That interface has methods for adding and removing elements, and so on. 4 Java Collections Frameworks: an overview
Image of page 2
3 5 Java Collections Frameworks: an overview List interface ° A list is a collection that remembers the order of its elements. ° Two implementing classes ± ArrayList ± LinkedList 6 Java Collections Frameworks: an overview Remember that… ° An ArrayList is simply a class containing an arra y that is expanded as needed. ° If you are not concerned about efficiency , you can use the ArrayList class whenever you need to collect objects. ° However, several common operations are inefficient with ArrayList . In particular, if an element is added or removed, the elements at larger positions must be moved.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 7 Java Collections Frameworks: an overview ° In many applications, you don’t really care about the order of the elements in a collection. ° Such a collection without an intrinsic order is called a set.
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern