关于java的实习生 [英] about intern in java

查看:118
本文介绍了关于java的实习生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,如果实习生正在使用字符串和字符串,它有一个
SPC(字符串池常量),而实习生概念也适用于整数,
那么是否有任何整数池常量?不是它的工作方式如何?

my question is if intern is working with string and string having a SPC(string pool constant) for it and intern concept also working with integer also, so is there any integer pool constant?if not then how its working?

class InternExample  
{  
 public void print()  
{    
 Integer i=10;  
 Integer j=10;  
 String c="a";  
  String s="a";  
 System.out.println(i==j);// prints true  
 System.out.println(c==s);//prints true  
}  
 public static void main(String args[])  
{  
  new InternExample().print();  
}  
}


推荐答案

已添加要 @Joachim Sauer 的答案,我们可以 更改上限缓存值

Added to @Joachim Sauer's answer, we can change the upper bound cache value.

部分选项是


  1. -Djava.lang.Integer.IntegerCache.high = value

  2. -XX: AutoBoxCacheMax = value

  3. -XX:+ AggressiveOpts

  1. -Djava.lang.Integer.IntegerCache.high=value
  2. -XX:AutoBoxCacheMax=value
  3. -XX:+AggressiveOpts

链接 Java专家

这篇关于关于java的实习生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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