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
Post a Comment