能在字符串数组中保存字符串变量吗?
String st1 = "",st2 = "",st3 = "",st4 = "";
String[] str = {st1,st2,st3,st4};
当我使用for循环,str能获取st1和st2的值,而st3 和 st4就显示不是它的变量。
所有我想把这些变量放在数组中,以下就是一个字符串数组的例子:
String[] containsValue = { "hi", "hello", "there" };
String strHi, strHello, strThere;
String[] getContainsValue = { strHi, strHello, strThere };
for (int x = 0; x < getContainsValue.length; x++) {
getContainsValue[x] = containsValue[x];
}
The value of:
strHi = "hi"
strHello = "hello"
strThere = "there";
基本意思就是想把containsValue []里的值转化为3个字符串: strHi,strHello,strThere ,然后存储在getContainsValue[]。这样做可以吗,有谁能给一个框架来解决这个问题?谢谢!