English 中文(简体)
这一职能是否每当被称作“新力量”?
原标题:Does this function create a new String everytime this is called?
  • 时间:2012-01-12 23:22:04
  •  标签:
  • java
  • string
public String toString()
{
     return "NotSubscribed";
}

我们试图限制在物体被瞬时发射之后我们的应用中创造力。 因此,在呼吁这样做的时候,这是否创造了新的力量。 这可能是一个坏的问题,但我不知道答案。 建议。

纽约总部

I just remembered that if a String is created, it is stored in the String Pool and after that it is always retrieved from the pool without being re-created. Am I right?

最佳回答

无,这每次都会产生另一个扼杀。 固定不变值为interated<>em>-因此,实际上,固定的“未登记”在你的代码上指同样的标语,甚至每当这种方法执行时都指此。

http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5” rel=“noreferer”>,Java 语特写第3.1.5节:

每一条字面字体都是指“强令”(第4.3.1节)中的一例(第12.5节)。 物体具有固定价值。 更一般地说,在字面上加载常表示的价值观(第15.28段)——“被点击”,以便使用“强硬”方法分享独特的事例。 内部。

然而,在你看来:

我刚刚记得,如果创造“强权”,则储存在“强权”库内,然后总是从集合中取回,而不必再造。 什么时候?

无。 缺省仅指constants。 例如,每当你管理该守则时,就:

public List<String> createStrings() {
    List<String> list = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
        list.add("foo" + i);
    }
    return list;
}

......这将产生另外10条指示。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...