Reputation:
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
Upvotes: 0
Views: 3017
Reputation: 4713
If its used a lot in your class, just declare a final String SPACE = " ";
and use it in the code when required.
private final String SPACE = " ";
String spaceString = "String1" + SPACE + "String2";
Upvotes: 0
Reputation: 74031
Your if statement is a little confusing to read
I would change it to
String text = string1 + " " + string2;
if(text.equals("string3")){
}
""
is not a space but " "
is a space
Upvotes: 2