Difference between container and wrapper
Asked Answered
I

1

18

In a programming language (e.g. Java), what's the difference between container and wrapper (or is there a difference). I've heard both the terms used vaguely.

Illailladvised answered 2/11, 2012 at 19:47 Comment(1)
This might help to define wrapper at least: en.wikipedia.org/wiki/Adapter_patternSilvertongued
K
51

In programming languages the word container is generally used for structures that can contain more than one element, for example a Map, a Set or a List. These structures normally provide methods like contains, that are semantically suitable if the object can contain more than one item.

A wrapper instead is something that wraps around a single object to provide more functionalities and interfaces to it. The typical example is the Integer class that in Java wraps the base type int.

Kreutzer answered 2/11, 2012 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.