Java Program To Count Occurrences Of Each Character in a String

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

ความคิดเห็น • 28

  • @bharathiyandra166
    @bharathiyandra166 3 ปีที่แล้ว +1

    i did not fount any channel like this .good explination and different programs ,,,,,,,,,,,,how many ways to solve a problem

  • @HasnathAli
    @HasnathAli 2 ปีที่แล้ว +1

    great.

  • @vincent1552
    @vincent1552 11 หลายเดือนก่อน

    Best video 🎉

  • @nammatulunadu7022
    @nammatulunadu7022 3 ปีที่แล้ว

    you didnt explain what is map,chaemapcount,hashmap etc,as a beginner very difficult to understand

    • @ProgrammingTutorials1M
      @ProgrammingTutorials1M  3 ปีที่แล้ว

      In my new videos, i have explained all the functions which is present used in code.

  • @rahulrathod8959
    @rahulrathod8959 3 ปีที่แล้ว +1

    Is it possible to solve this problem without using map data structure??

  • @arjunkhanna1803
    @arjunkhanna1803 4 ปีที่แล้ว

    id doesn't work if we want to count char frequency ignoring the case of char
    ex : if i write Aarjun then freq of A =1 and a =1
    what to do in this situation??

    • @ProgrammingTutorials1M
      @ProgrammingTutorials1M  4 ปีที่แล้ว

      You have to ignore the letter case.

    • @areukiddinme8438
      @areukiddinme8438 3 ปีที่แล้ว

      you can apply either (string name.toUpperCase) or (string name.toLowerCase) and store it back to the same string if ya want.
      by now i think u already know haha

  • @Amitkumar-xy2kw
    @Amitkumar-xy2kw ปีที่แล้ว

    bhai thoda tej bolo please i could hardly hear you..

  • @mohammedajazquadri7869
    @mohammedajazquadri7869 4 ปีที่แล้ว

    Get(c)+1 what is purpose of adding 1 ??

    • @ProgrammingTutorials1M
      @ProgrammingTutorials1M  4 ปีที่แล้ว

      It means we are incrementing the value by 1 whenever we encounter the same value.

  • @belcruz25
    @belcruz25 6 ปีที่แล้ว

    what if the user want to check the occurrence of three or more letters. for example the user input a string: "how are you" and user want to get the occurrence for the letter: oru what will be the code?

    • @ProgrammingTutorials1M
      @ProgrammingTutorials1M  6 ปีที่แล้ว

      Hi Rosabel, In this case print the occurrence of only these characters.

    • @belcruz25
      @belcruz25 6 ปีที่แล้ว

      for(int i = 0; i< sentence.length(); i++){for(int x=0; x

    • @ProgrammingTutorials1M
      @ProgrammingTutorials1M  6 ปีที่แล้ว +1

      Create a map of character and count. And then add the count of characters.
      Map charMapCount = new HashMap();
      for(Character c : str.toCharArray()) {
      if(charMapCount.containsKey(c)) {
      charMapCount.put(c, charMapCount.get(c) + 1);
      } else {
      charMapCount.put(c, 1);
      }
      }
      int count = 0;
      int sum = 0;
      for(Map.Entry entry : charMapCount.entrySet()) {
      //Check for character and the do the sum
      if(charMapCount.containsKey(ch)) {
      sum = sum + charMapCount.get(ch);
      }
      }

    • @belcruz25
      @belcruz25 6 ปีที่แล้ว +1

      Thanks. I will try it

  • @HOPE98901
    @HOPE98901 3 ปีที่แล้ว

    your sound is so low

  • @neelshah720
    @neelshah720 5 ปีที่แล้ว +4

    shortest man 😎 well explained just speak little more loud

  • @keerthidammu7700
    @keerthidammu7700 5 ปีที่แล้ว +2

    Well... explained 😃

  • @pratheekbhat2758
    @pratheekbhat2758 6 ปีที่แล้ว

    Which application are u using to compile java?