博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
String java.lang.String.intern()的作用
阅读量:7045 次
发布时间:2019-06-28

本文共 900 字,大约阅读时间需要 3 分钟。

  hot3.png

NOTE:intern方法是native方法

String java.lang.String.intern()

Returns a canonical representation for the string object. 

A pool of strings, initially empty, is maintained privately by the class String. 

When the intern method is invoked, if the pool already contains a string equal to this String object as determined by theequals(Object)method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.

It follows that for any two stringssandt,s.intern() == t.intern() is true if and only if s.equals(t) is true. 

All literal strings and string-valued constant expressions are interned. String literals are defined in §3.10.5 of the Java Language Specification Returns:a string that has the same contents as this string, but is guaranteed to be from a pool of unique strings. 

转载于:https://my.oschina.net/0xphil/blog/129444

你可能感兴趣的文章
dubbo服务配置sentinel
查看>>
亚马逊下架一款智能玩具,几维安全提醒智能终端安全不容忽视
查看>>
计算机指令在CPU中的执行过程(图文版)
查看>>
理解 iOS 和 macOS 的内存管理
查看>>
Ajax (部分一)自己做的,总结页面向后台传Form值、单个值和后台向前台传一个或是一组值...
查看>>
web缓存技术
查看>>
集合知识点
查看>>
Linux快捷键
查看>>
文档对象模型DOM
查看>>
2019北京国际康复及个人健康博览会将在中国国际展览中心举办
查看>>
JVM——类加载机制(一)
查看>>
超清晰的 DNS 原理入门指南 (资源)
查看>>
大神笔记
查看>>
spring cloud构建java b2b2c 电子商务云商平台
查看>>
阿里在使用一种更灵活的软件集成发布模式
查看>>
阿里顶级Java架构师,教你这样手写Spring!
查看>>
android课程表控件、悬浮窗、Todo应用、MVP框架、Kotlin完整项目源码
查看>>
比特币现金的未来取决于采用而非投资
查看>>
Kafka从入门到进阶
查看>>
传统IDC部署网站(二)
查看>>