I want to get the numbers of a given string and I used the code as below
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);
The Result is: output :7011
Is there any simple way to get the output?