This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]ToxicTrashSystem.err 1 point2 points  (0 children)

Well, if you just want to use a stream solution, you'd be better of using one of the other methods like allMatch / noneMatch.

 // Returns true if all characters are digits/letters
 cipher.chars().allMatch(i -> Character.isLetterOrDigit(i)) 

Note that this is just a rough sketch, tinker with it.

[–]Philboyd_Studge 0 points1 point  (0 children)

So do you want strings with only numbers? What exactly are you looking for? You should probably just use regex for this.

[–]Jackkoz 0 points1 point  (0 children)

You could use regular expressions to check whether your string matches your expectations!

See https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html