博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
语言编程写法
阅读量:7179 次
发布时间:2019-06-29

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

public class TestStr {

public static void main(String[] args) {
// 以下两条语句创建了1个对象。"凤山"存储在字符串常量池中
String str1 = "凤山";
String str2 = "凤山";
System.out.println(str1==str2);//true

//以下两条语句创建了3个对象。"天峨",存储在字符串常量池中,两个new String()对象存储在堆内存中 String str3 = new String("天峨"); String str4 = new String("天峨"); System.out.println(str3==str4);//false //以下两条语句创建了1个对象。9是存储在栈内存中 int i = 9; int j = 9; System.out.println(i==j);//true   //以下两条语句创建了1个对象。1对象存储在栈内存中 Integer l = 1;//装箱 Integer k = 1;//装箱 System.out.println(l==k);//true //由于没有了装箱,以下两条语句创建了2个对象。两个1对象存储在堆内存中 Integer l1 = new Integer(1); Integer k1 = new Integer(1); System.out.println(l1==k1);//false //以下两条语句创建了1个对象。i1,i2变量存储在栈内存中,两个256对象存储在堆内存中      Integer i1 = 256;             Integer i2 = 256;      System.out.println(i1==i2);//false

}

转载于:https://blog.51cto.com/14311959/2394163

你可能感兴趣的文章
数据库有基础知识
查看>>
最大值最小化 题解
查看>>
python 使用mysql示例
查看>>
洛谷P1717 钓鱼
查看>>
Angular2组件开发—调用服务(三)
查看>>
web服务器部署
查看>>
旧机改造步骤
查看>>
步步为营:因为数据库正在使用,所以无法获得对数据库的独占访问权
查看>>
webpack.config.js====entry入口文件的配置
查看>>
python SendMail 发送邮件
查看>>
Python数据整合与数据准备-BigGorilla应用
查看>>
测温补偿测试程序
查看>>
几何画板有哪些快捷键可以用
查看>>
01.mp4v2应用—mp4转h264
查看>>
熟悉常用的HDFS操作
查看>>
置顶广告
查看>>
PLSQL Developer
查看>>
数据库
查看>>
函数声明和函数定义的区别
查看>>
2013长沙网络赛,Problem G,Goldbach,解题报告
查看>>