日期:2014-05-19  浏览次数:20651 次

java 面试
String s = "a" + "b" + "c" + "d" + "e"; 问此语句共创建了几个对象

请给出分析过程

------解决方案--------------------
下了个反编译工具看了下

却实是哈
源码这是:
package com.string;

public class test {
public static void main(String[] args) {
String s = "a"+"b"+"c"+"d"+"e";
}
}


这是反编译后的代码

// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date: 2010-8-15 上午 10:56:49
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name: test.java

package com.string;


public class test
{

public test()
{
}

public static void main(String args[])
{
String s = "abcde";
}
}