Java Program to Find the occurrence count of each character in the String using the HashMap

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • This video will help you to write the program to find the occurrence of each character in the given string using the concept of hashmap in java

Комментарии • 21

  • @maniyaa_
    @maniyaa_ Год назад +1

    This has helped me very much! thank you friend.

  • @parichaymadnani9677
    @parichaymadnani9677 4 года назад +2

    nice video bro !! every line was explained properly

  • @ridhim4235
    @ridhim4235 2 года назад

    hey i need to use the same concept of just instead of counting no of occurrences i want to grab there index key values
    for ex: string =javais
    what that hashmap should look like is {
    j:0,
    a:1,3
    v:2
    and so on...
    }
    could you help me out

  • @tripletbaba722
    @tripletbaba722 3 года назад +1

    thankyou🖤

  • @lesterdelacruz309
    @lesterdelacruz309 2 года назад +3

    String s ="Java";
    HashMap h = new HashMap();
    char []c = s.toCharArray();
    for(Character i: c)
    {
    if(h.containsKey(i))
    {
    h.put(i,h.get(i)+1);
    }
    else
    {
    h.put(i,1);
    }
    }
    Set set = h.keySet();
    for(char c2 : set)
    {
    System.out.println("Char: "+c2+" "+h.get(c2));
    }

  • @leslieaikpe7762
    @leslieaikpe7762 3 года назад +1

    thk you very much

  • @sharma3226
    @sharma3226 2 года назад +1

    Sir could you Pleasee guide me how to sort number of frequent words used in pdf document. because i want to learn the most important major words for exam would be very helpful 🙏🏽🙏🏽.

  • @avs9171
    @avs9171 4 года назад +2

    can u add the code link so we can use it directly

  • @SanjaySinghYT
    @SanjaySinghYT 5 месяцев назад

    // Easiest Solution
    public static void main(String[] args) {
    String text = "Sanjay";
    HashMap hashmap = new HashMap();
    for(int i=0; i< text.length(); i++)
    {
    char ch = text.charAt(i);
    int count=0;
    if(hashmap.containsKey(ch))
    {
    count = hashmap.get(ch);
    }
    hashmap.put(ch, ++count);
    }
    System.out.println(hashmap);
    }

  • @gauravsinghrajput5959
    @gauravsinghrajput5959 Год назад

    Where is a

    • @shekharbirajdar
      @shekharbirajdar  Год назад

      What exactly you mean to ask I didn't understood. Can you elaborate in detail

  • @Diego0wnz
    @Diego0wnz 3 года назад +1

    python IS BETTER

    • @apjhardy619
      @apjhardy619 2 года назад +1

      Said every developer who couldn't handle complex codes that offer way better security.