String面试题


//a b c 分别是怎么存储的, a和b a和c分别有什么区别
// c和d的区别是什么


String a= "hello";
String b= "hello"+"world";
String c= new String("hello");
String d= new String("hello")+new String("world");
//System.out.println(c);

System.out.println(c); 
在被注释的时候c就没有定义了,d还是会有定义,这是为什么呢
String a = "hello";
String b = "helloworld";
new String("hello");
String d = new String("hello") + new String("world");
===
String a= "hello";
String b= "hello"+"world";
String c= new String("hello");
String d= new String("hello")+new String("world");
System.out.println(c);

String a = "hello";
String b = "helloworld";
String c = new String("hello");
String d = new String("hello") + new String("world");
System.out.println(c);

====
String a;
System.out.print(a);

err:
未初始化的参数 a

常量池在java用于保存在编译期已确定的,已编译的class文件中的一份数据。它包括了关于类,方法,接口等中的常量,也包括字符串常量,如String s = "java"这种申明方式;当然也可扩充,执行器产生的常量也会放入常量池,故认为常量池是JVM的一块特殊的内存空间。

 jstat,jmap,jstack

 2015/9/24 11:42:46

我一般用jstat -gc -gcutil比较多

 2015/9/24 11:42:51

看堆内存的占用情况

 2015/9/24 11:43:07

看string这种,可以看字节码 
posted on 2015-09-23 17:53  viewcozy  阅读(270)  评论(0编辑  收藏  举报