Friday, March 23, 2018

Write a Java Program to take an String array like this String[] s={"Welcome","to","2018","hi","17"} and filter only numbers.


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.
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]


Share this

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