我有两个字符串
String str1= "B0000001";
String str2= "Testing";
StringBuilder sb= new StringBuilder();
sb.append(str1)
sb.append("\\");
sb.append(str2);
return sb.toString();
我得到的结果是“B0000001”\“测试”
但我希望结果为“B0000001 \ Testing”
我怎样才能实现它?
答案 0 :(得分: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