English 中文(简体)
如何将价值分配给一个匿名的阵列,而不是最初设定?
原标题:How to assign values to an anonymous array other than initializing it?

方法只接受匿名阵列,例如:

setSomeValue(new String[] { v1 ,  v2 ,  v3 ));

I want to copy the values of another array into this anonymous array before sending it to the setSomeValue method.

The 价值方法:

public void setSomeValue(String[] pArrayName) { vararray = pArrayName; } 

public void getSomeValue() { return vararray;} 

但是,Some的所在地 价值指一些Rql Query等。

QueryExpression valueQE =
    pQueryBuilder.createConstantQueryExpression(getSomeValue());

我认为,这一方法的关键是<条码>。 但是,在I m 设置Sting[]阵列,但自匿名以来,它被当作目标对待。

ANSWER: Sorry guys for conting You. 是的,你全心全意地低估了你的sel。 问题是,正在产生的询问不是正确的,有些问题涉及内容,各个阵列本身是否是一个匿名阵列进行了适当的处理。 “YES”和“YES”没有一种条件,即一种方法只能接受匿名的阵列(在此情况下不是)。

问题回答

如果你想把一个阵列的拷贝复制成一种方法,则尝试:

setSomeValue(Arrays.copyOf(arr, arr.length));

复制一个阵列的最简单方式是使用衣物。

String[] array = "v1,v2,v3".split(",");
String[] someOtherArray = array.clone();
setSomeValue(someOtherArray);

BTW: 这本是一份浅印本。





相关问题
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 ...

热门标签