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
This has helped me very much! thank you friend.
Glad it helped!
nice video bro !! every line was explained properly
Thanks for support
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
Sure I will soon make video on the same
thankyou🖤
if you liked it do like share and subscribe
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));
}
thk you very much
If you liked it do like share and subscribe
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 🙏🏽🙏🏽.
Okay
can u add the code link so we can use it directly
Soon i will do it
@@shekharbirajdar we are still waiting :)😅
// 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);
}
Where is a
What exactly you mean to ask I didn't understood. Can you elaborate in detail
python IS BETTER
Said every developer who couldn't handle complex codes that offer way better security.