Print Only Numbers From Java Strings

I have a question in Java-string,
String s="adf5hgjyu1frdsff6vgyu7bnjh9asd3"; like
How to print only numbers in that string

Showing Answers 1 - 4 of 4 Answers

Amarendra

  • Oct 6th, 2015
 

Code
  1. span style="color: #ff0000;">"adf5hgjyu1frdsff6vgyu7bnjh9asd3"", "//System.out.print(sarr[i]+", ");

  2.                         }

  3.                 }

  4.         }

  Was this answer useful?  Yes

amrendra

  • Oct 6th, 2015
 

Check with ascii codes

Code
  1. span style="color: #0000ff;">"adf5hgjyu1frdsff6vgyu7bnjh9asd3"", "//System.out.print(sarr[i]+", ");

  2.                         }

  3.                 }

  4.         }

  Was this answer useful?  Yes

rawatfeb

  • Feb 23rd, 2016
 

private static void NumericsFromStringTest() {
String alphaNumericString = "h8ll0";
char[] carray = alphaNumericString.toCharArray();
for (char c : carray) {
if (Character.isDigit(c)) {
System.out.println(c);
}
}
}

Code
  1. span style="color: #0000ff;">"h8ll0"

  Was this answer useful?  Yes

Vincent

  • Jan 11th, 2018
 

Run someCode() method from main()

Code
  1. span style="color: #0000ff;">"adf5hgjyu1frdsff6vgyu7bnjh9asd3""the number is "+n+" and it is ""Prime""Not Prime""Prime";

  2.         }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions