java - counting instances of int in a string -


trying count how many integers within string

system.out.println("enter numbers, eg 1 2 3: "); = scan.nextline(); b = count(a).length; 

this not work. there simple method this?

try this

    matcher m = pattern.compile("\\d++").matcher(input);     int n = 0;     while(m.find()) {         n++;     } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -