Difference between container and wrapper

后端 未结 1 783
粉色の甜心
粉色の甜心 2021-02-01 23:30

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

相关标签:
1条回答
  • 2021-02-02 00:04

    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.

    0 讨论(0)
提交回复
热议问题