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

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

问题描述

在编程语言(例如 Java)中,containerwrapper 有什么区别(或者有区别).我听说这两个术语都含糊其辞.

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.

推荐答案

在编程语言中,container这个词通常用于可以包含多个元素的结构,例如 Map集合列表.这些结构通常提供像 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天全站免登陆