Write a Java Program to take an String array like this String[] s={"Welcome","to","2018","hi","17"} and filter only numbers.
class FilterNumber
{
public static void main(String[] args)
{
String[] s={"Welcome","to","2018","hi","17"};
for(String n:s)
{
try
{
System.out.println(Integer.parseInt(n));
}
catch (NumberFormatException e)
{}
}
}
}
Write a Java Program to take an String array like this String[] s={"Welcome","to","2018","hi","17"} and filter only numbers. [All Java Interview programs] |
0 Comment to "Write a Java Program to take an String array like this String[] s={"Welcome","to","2018","hi","17"} and filter only numbers."
Post a Comment