Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.regex.*;
- import java.awt.*;
- class MySt {
- private String m_str;
- public MySt(String s) {
- this.m_str = s;
- }
- public String getStr() {
- return m_str;
- }
- public String getReverse() {
- String reverse = new StringBuffer(this.m_str).reverse().toString();
- return reverse;
- }
- public void kolvo (char a) {
- int o = 0;
- String [] p = this.m_str.split("");
- for(int i = 0; i <m_str.length();i++)
- if (a == this.m_str.charAt(i))
- o++;
- System.out.println("колличество совпадений :"+o);
- }
- static void fill (HashMap<String, Integer> dictionary, String source) {
- String[] words = source.split("[, .;?!:]");
- for (String word : words)
- if (!word.isEmpty())
- if (!dictionary.containsKey(word))
- dictionary.put(word, 1); //
- else
- dictionary.put(word, dictionary.get(word) + 1);
- }
- static boolean validBrack(String s) {
- String reg = "{|}|(|)|[|]";
- Pattern p = Pattern.compile(reg);
- Matcher m = p.matcher(reg);
- boolean b = m.matches();
- if(b) return true;
- else return false;
- }
- public static void main(String [] args) {
- /*char p = 'm';
- MySt s = new MySt("qwertyuiopasdfghjklzxcvbnmmmmm");
- System.out.println(s.getReverse());
- s.kolvo(p);
- HashMap<String, Integer> dictionary = new HashMap<String, Integer>();
- String sourceOfWords = "haha haha lol LOL привет ;; как дела дела дела как дела дела дела hello собака собака каталась";
- String newStr = sourceOfWords.toLowerCase();
- fill (dictionary, newStr);
- for (String key : dictionary.keySet())
- System.out.println (key + ": " + dictionary.get(key));*/
- System.out.println(validBrack("{}{"));
- }
- }
Add Comment
Please, Sign In to add comment