我有一个由 6 个字母组成的字符串,例如:“abcdef”。我需要添加“。” 每两个字符,所以它会是这样的:“ab.cd.ef”。我在java中工作,我试过这个:
private String FormatAddress(String sourceAddress) {
char[] sourceAddressFormatted = new char[8];
sourceAddress.getChars(0, 1, sourceAddressFormatted, 0);
sourceAddress += ".";
sourceAddress.getChars(2, 3, sourceAddressFormatted, 3);
sourceAddress += ".";
sourceAddress.getChars(4, 5, sourceAddressFormatted, 6);
String s = new String(sourceAddressFormatted);
return s;
}
但我收到了奇怪的值,例如 [C@2723b6.
提前致谢:)