battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Share
 

 java class that filter numbers out of a string

Go down 
AuthorMessage
Moti Barski

Moti Barski

Posts : 330
Join date : 2011-08-02

java class that filter numbers out of a string Empty
PostSubject: java class that filter numbers out of a string   java class that filter numbers out of a string EmptyMon Jul 30, 2018 11:20 am

Code:
public class Numerize {
    final static private String allnums = "0123456789";
    public  static  String filter(String s1){
        char[] arr = s1.toCharArray();
        String result="";
        for (char ot:arr) {
            if(allnums.contains(ot + "")){result+= ot;}
        }
        return result;
    }
}

🐷

_________________
MB over and out emp it up
Back to top Go down
View user profile
 
java class that filter numbers out of a string
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: