-2

我有两个字符串

String str1= "B0000001";
String str2= "Testing";

StringBuilder sb= new StringBuilder();
sb.append(str1)
sb.append("\\");
sb.append(str2);
return sb.toString();

我得到的结果是“B0000001”\“测试”

但我希望结果为“B0000001\Testing”

我怎样才能实现它?

4

1 回答 1

3
  String str1 = "B0000001";
  String str2 = "Testing";
  StringBuilder sb = new StringBuilder();
  sb.append(str1);
  sb.append("\"\\\"");///////////(\")--->for (") and (\\) for(\) and (\")-->for (")
  sb.append(str2);
  System.out.println( sb.toString());

输出为:B0000001"\"测试

String str1= "B0000001"
String str2= "Testing"

StringBuilder sb= new StringBuilder();
sb.append(str1)
sb.append("\\");
sb.append(str2);
return sb.toString();

输出为:B0000001\Testing

于 2013-03-27T20:28:11.370 回答