0

I am trying to concatenate two strings with a space in between as follows:

if(searchSymbol.toLowerCase().contains(mSearchView.getText().toString().toLowerCase()) + "HERE COMES THE SPACE" +searchSymbol.toLowerCase().contains(mSearchView.getText().toString().toLowerCase())  )

{}

I am just not sure how to define the same? should I use (1st string&&+""&&""+ 2nd string). Any help appreciated.

Thanks! Justin

4

2 回答 2

2

你的 if 语句读起来有点混乱

我会把它改成

String text = string1 + " " + string2;

if(text.equals("string3")){

}

""不是空间而是" "空间

于 2013-09-10T20:52:50.017 回答
0

如果它在您的类中使用很多,只需声明 afinal String SPACE = " "; 并在需要时在代码中使用它。

private final String SPACE = " ";
String spaceString = "String1" + SPACE + "String2";
于 2013-09-10T21:08:39.500 回答