1 2 Previous Next 16 Replies Latest reply: Feb 28, 2008 11:01 AM by 807591 RSS

    Operator ++ on Character?

    807591
      I have to make an excerise for school,

      program is supposes to Keep count of the times a character has been typed in a string.


      i'm realy stuck on the part where i have to count the chars

      can somebody help me out please

      so here is my code so far
      public class Letters {
      
          private String invoer;
          private HashMap <Character,Integer> chars;
          
          
      
          public Letters() {
      
              chars = new HashMap<Character,Integer>();
              
              
          }    
      
      
          public void read() {
               Scanner scanner = new Scanner(System.in);
               scanner.useDelimiter("\n");
               System.out.print("Geef een zin:");
               invoer = scanner.next();
           }
      
       
          public void count() {
              
              for(int i=0;i<chars.size();i++){
                  
                  switch (invoer.charAt(i))
                  {
                      case 'a' : Letters.put('a',character(a)); break;
                  
                  
                  
                  }
              
              
              
              
              
              }
              
      
          }    
          
      
      
          public void showCharacters() {
              
          }    
          
      }
      Edited by: muckv on Feb 28, 2008 8:21 AM
        1 2 Previous Next