容器和包装纸之间的区别 [英] Difference between container and wrapper

查看:150
本文介绍了容器和包装纸之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一种编程语言(例如Java)中,容器包装器有什么区别(或者是否有区别)。我听说过两个词都含糊不清。

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.

推荐答案

在编程语言中,容器一词通常用于包含多个元素的结构,例如 Map Set List 。这些结构通常提供 contains 之类的方法,如果对象可以包含多个项目,则在语义上是合适的。

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.

相反,包装器是包裹单个对象以提供更多功能和接口的东西。典型示例是 Integer 类,该类在Java中包装了基本类型 int

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.

这篇关于容器和包装纸之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆