Java 中的对等类是什么?

发布于 2024-10-09 16:59:56 字数 74 浏览 0 评论 0原文

我发现 StringBuffer 被称为 String 的对等类。什么是同侪班级?

I came across the fact StringBuffer is called peer class of String. What is a peer class?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦开始←不甜 2024-10-16 16:59:56

首先:您必须小心使用术语“对等类”,因为在 Java 中它具有独特的含义:对等类是本机类的“接口”。 (例如 C++ 类)(有关详细信息,请参阅其他答案)

在您的情况下,该术语似乎在特定上下文中使用!

无论谁将 StringBuffer 称为 String 的对等类,显然都在一般意义上使用了该词。在某种程度上,StringBufferString 是相关的,并且它们都可以用于类似的目的。我想在某些用例中,他们可以被视为更广泛意义上的同行。

First of all: You have to be careful with the term "peer class", because in Java it has a distinct meaning: Peer classes are "interfaces" to native classes. (a C++ class for example) (See the other anwsers for details)

In your case the term seems not to be used in that specific context!

Whoever called StringBuffer a peer class to String obviously used that word in a general sense. In a way StringBuffer and String are related and both of them can be used for similar purposes. I guess in some use cases they could be considered peers in the broader sense of the word.

云归处 2024-10-16 16:59:56

据我所知,编写对等类是为了将代码与本机代码连接起来。
请参阅这篇文章,http://javapapers.com/core-java/java-peer-类/

As I know, peer classes are written to connect the code with the native code.
See this article, http://javapapers.com/core-java/java-peer-class/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文