特定の文字列の数字を取得したいので、以下のコードを使用しました
String sample = "7011WD";
String output = "";
for (int index = 0; index < sample.length(); index++)
{
if (Character.isDigit(sample.charAt(index)))
{
char aChar = sample.charAt(index);
output = output + aChar;
}
}
System.out.println("output :" + output);
結果は次のとおりです。 出力:7011
出力を取得する簡単な方法はありますか?