Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Set;
- import java.util.TreeSet;
- public class LineCharLimiter {
- private final Set<Character> chars = new TreeSet<>();
- public LineCharLimiter(String chars){
- for(char ch : chars.toCharArray()){
- this.chars.add(ch);
- }
- }
- public String handle(String str){
- for(char ch : str.toCharArray()){
- if(!this.chars.contains(ch))
- return null;
- }
- return str;
- }
- }
Add Comment
Please, Sign In to add comment