Draft:Heterogeneous Collections
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
|
Comment: see WP:LLM for more information. ~ŤheŴubṂachine-840≈ ● ✒️ 00:55, 29 April 2026 (UTC)
'''Heterogeneous collection''' is a term in computer science for a data structure or container that can hold elements of more than one data type.
== Definition ==
A heterogeneous collection is a container that holds elements of different types. This contrasts with a homogeneous collection, which holds only one type (for example, List<int> or an array of doubles).
Introductory teaching material from Tufts University uses struct as an example of an aggregate type that can combine fields of different types, describing such aggregates as a way to represent heterogeneous data. Tufts University ECE and CS Departments, “Comp 11: Heterogeneous Aggregate Storage”.
In Java, a collection declared with element type Object can store values of different runtime types (for example, String, numeric wrapper types, and custom classes), although this approach typically relies on runtime type checks and casts. See javaspring.net, “What is a Heterogeneous Object in Java? Understanding Collections with Object Class and Mixed Types”.
== Use cases ==
Heterogeneous collections are used when a program needs to represent or exchange values that do not share a single uniform type, including:
* Representing a single conceptual entity with multiple attributes of different types (for example, a struct with string, integer, and boolean fields).
* Supporting extensible systems that must accept values of many possible types (for example, serialization, dependency injection, or messaging systems).
* Modeling dynamically typed data formats (for example, JSON values that may be strings, numbers, arrays, or objects).
== Examples ==
* Records and structs: Aggregate types can combine fields of multiple types in a single value.
* Universal-base-type containers: Some statically typed languages allow collections whose element type is a top type such as Object (Java), enabling storage of different runtime types in one collection.
* JSON DOM models: Libraries may represent any JSON value using a single node type (for example, a tagged union).
* Dynamically typed languages: In languages such as Python and JavaScript, list/array types can commonly store mixed element types.
== Trade-offs ==
Heterogeneous collections can improve flexibility, but they are often associated with reduced static type guarantees and additional runtime checking in statically typed languages.
== Potential advantages ==
* Flexibility for loosely structured data
* Convenience for infrastructure code that must accept arbitrary payloads ;Potential disadvantages * Reduced compile-time type safety (elements may require casts)
* Increased likelihood of runtime type errors (for example, ClassCastException)
* Possible performance overhead from type checks, boxing, or dynamic dispatch
== See also ==
* Record (computer science)
* Tagged union
* Type system
* Polymorphism (computer science)
* Generics in Java
== External links == *http://www.eecs.tufts.edu/~msheldon/cs15_2021s_summary/reference/comp11_structs/index.shtml
* https://www.javaspring.net/blog/what-is-an-heterogeneous-object-in-java/
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.

LLM-generated pages with certain obvious signs of being machine generated may be deleted without notice.
These tools are prone to specific issues that violate our policies:
Instead, only summarize in your own words a range of independent, reliable, published sources that discuss the subject.
See the advice page on large language models for more information.