Java Programming Assignment: Collection Framework Comparison

Verified

Added on  2023/01/17

|4
|747
|51
Homework Assignment
AI Summary
This Java programming assignment provides a detailed analysis of the Java Collection Framework (JCF), comparing it to the C++ collection framework. The assignment explores the representation of Lists, Sets, and Maps within JCF, highlighting the use of interfaces like Collection, List (ArrayList), and Map (HashMap). It also covers sorting mechanisms within the framework, discussing the use of the `sort()` method from the `Collections` class and the `TreeSet` for sorting set elements. Furthermore, the assignment outlines the benefits and drawbacks of using the Java Collection Framework, such as providing standard interfaces and useful data structures while lacking compile-time type checking. The assignment includes a bibliography with relevant research papers and patents. The provided solution is designed to help students understand and solve similar Java programming assignments, making it a valuable resource for those studying computer science and related fields, available on Desklib.
Document Page
Running head: JAVA PROGRAMMING
JAVA PROGRAMMING
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
JAVA PROGRAMMING 1
1. Difference between java collection framework and C++ collection framework:
SL
no.
Java collection framework C++ collection framework
1. All of the algorithms have been organised by the
containers.
The algorithms are having
independency for the
containers on that they can
operate.
2. This function is does not exist in java collection
framework.
It includes the performance as
one of the parts of the
requirements for the interface.
3. Java heavily relies on the interfaces. It cannot rely on the
interfaces.
4. The containers are able to contain only the
algorithms and the objects that have to be
separately defined for the containers as well as
for the arrays.
The containers are able to
contain either primitive type
objects or the only the objects
as well as many of the
algorithms for operating on
either arrays or on the
containers.
5. These factors are not available in java collection
framework.
The model of the memory
allocation is a part of this
framework as well as the
programmes need to aware of
the memory that is considered
as deallocating.
6. The passing functions are not allows as
parameter.
The passing functions ae
allows as parameter.
2. How does JCF represent Lists, Sets, and Maps?
The collection interface of java is an interface that is general and includes the sub interfaces
that are List, sets and maps. If one of the method is having a type of parameter that is
Collection, like the addALL (collection coll) method. It can be passed as a set or list and that
will work fine. The list is considered as an interface however, the ArrayList is the typically
used class that is able to implement the Lists. On the other side the interface that is related to
Document Page
2JAVA PROGRAMMING
the map is different from the collection interface. A value or key dictionary is defined by the
map interface however Hashmap is one of the most commonly used map.
3. Sorting in collection framework?
The collection class is a method that is static in type for the sort of the elements that are
included in the collection. If the elements of the collection are of Set in type, then the TreeSet
can be used. However, the elements that are included in the List cannot be sorted. The
method for sorting of the elements that are included in List type elements, is provided by the
Collection Class,
The method:
public void sort(List list): is utilized for sorting the elements that are included in List. The
elements of the List have to be Comparable in type.
4. Benefits and drawbacks of different collection framework:
Benefits:
The programmers require to learn the multiple ad hoc collection APIs.
An interface that is standard for the collections are provided by this, that are reutilized
by the fosters software as well as provides also the algorithms too for manipulating
them.
The data structures that are useful are provided, also it provides the algorithms that
can reduce the effort for the programming.
Drawbacks:
This cannot be done the compile time checking type.
It has to cast for correct type.
Document Page
3JAVA PROGRAMMING
Bibliography:
Manotas, I., Pollock, L. and Clause, J., 2014, May. SEEDS: a software engineer's energy-
optimization decision support framework. In Proceedings of the 36th International
Conference on Software Engineering (pp. 503-514). ACM.
Ortiz, C.N., International Business Machines Corp, 2013. Automatic collection of diagnostic
traces in an automation framework. U.S. Patent 8,359,581.
Ortiz, C.N., International Business Machines Corp, 2013. Automatic collection of diagnostic
traces in an automation framework. U.S. Patent 8,359,581.
Pereira, R., Couto, M., Saraiva, J., Cunha, J. and Fernandes, J.P., 2016, May. The influence
of the Java collection framework on overall energy consumption. In Proceedings of the 5th
International Workshop on Green and Sustainable Software (pp. 15-21). ACM.
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]