Anyone know how to display the punctuations used in a text area , I used hash map. so here is my code of my hash map
i was also thinking of using linear search and combine a if statement, if it is found display it.
The jta.text(); is the name of my text thing. basically wat i have in my text box.

private void countWords()
    {
        int numwords;
        String text = jta.getText();;
            
    // Create a hash map to hold words as key and count as value
   /Map<String, Integer> hashMap = new HashMap<String, Integer>();

    String[] words = text.split("[ .!?\\n-]");
    numwords = words.length;
    System.out.println("Number of words: " + numwords);
    
    for (int i = 0; i < words.length; i++) {
      if (words[i].length() > 1) {
        if (hashMap.get(words[i]) != null) {
          int value = hashMap.get(words[i]).intValue();
          value++;
          hashMap.put(words[i], value);
        }
        else
          hashMap.put(words[i], 1);
      }
    }

    // Create a tree map from the hash map
    Map<String, Integer> treeMap =
      new TreeMap<String, Integer>(hashMap);

    // Display mappings
    System.out.println("Display words and their count in " +
      "ascending order of the words");
    System.out.print(treeMap);
        
    }

im 1 step away from completing this
see my other full code in some other post

please help

oh yes and if anyone know any way to combine equalsIgnoreCase case thing in my hash map, when im doing the Total Words thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.