当使用交互面板运行我的代码时,我在结果之前得到一个空值。例如当我输入:第一个词 - 谷歌第二个词 - 铬
结果应该是 - gcohorgolme 但它是 - nullgcohorgolme
任何想法为什么?这是我的代码:
public class Collate{
String result;
String x;
String y;
public String collate(String x, String y){
for(int i = 0; i < x.length(); i++)
{
result += x.charAt(i);
result += y.charAt(i);
}
return (result);
}
}
非常感谢!