2 Replies Latest reply: Feb 27, 2007 10:49 AM by 807606 RSS

    Using  String method- help

    807606
      um, I am writting an application that inputs a line of text and uses String method to determine the total number of occurrences of a letter for ex. "e" of the alphabet in the text...but there is something wrong and I am guessing its "add" place..not sure tho but I will keep trying, still need your help, thanks.
           String word= JOptionPane.showInputDialog("Enter any text");
                     int index, add=0;
                     for (index=0; index<=word.length();index++){
                     if (word.charAt(index)=='e')
                     add++;
           }      
                      System.out.println(add);
      this is the peace of code I need help with..