空白とピリオドを含む文字列を置き換える必要があります。私は次のコードで試しました:
String customerName = "Mr. Raj Kumar";
customerName = customerName.replaceAll(" ", "");
System.out.println("customerName"+customerName);
customerName = customerName.replaceAll(".", "");
System.out.println("customerName"+customerName);
しかし、これは次の結果になります:
顧客名 Mr.RajKumar
と
顧客名
最初の SOP からは正しい顧客名を取得していますが、2 番目の SOP からは値を取得していません。