7 Replies Latest reply on Aug 11, 2008 8:26 PM by 843785

    counting char with arrays Help

      here is my program but i am stuck on one part. what it does is you type in something name,word,anything it prints how many letters are in the name or word. i gave each array a value and used scanner to get user input all i have to do is tell the program to count. how do i do that??? thanks for any help

      import java.util.*;
      public class LettersInMyName {
         public static void main(String []args) {
           Scanner myScanner = new Scanner(System.in);
           char[] myArrayname;
           char myScan1, myScan2, myScan3, myScan4;
           myArrayname = new char[4];
             myScan1 = myScanner.findInLine(".").charAt(0);
             myScan2 = myScanner.findInLine(".").charAt(0);
             myScan3 = myScanner.findInLine(".").charAt(0);
             myScan4 = myScanner.findInLine(".").charAt(0);
             myArrayname[0] = myScan1;
             myArrayname[1] = myScan2;
             myArrayname[2] = myScan3;
             myArrayname[3] = myScan4;