Write Java program to count Character Occurrences in given string

preview_player
Показать описание
Learn Java Program -input -aabbbc / Ouput - a2b3c1
Рекомендации по теме
Комментарии
Автор

Great explanation... Pls provide more interview program thanks madam🙏

dipaksahane
Автор

good teacing all the best for birght future

Sandeepreddy
Автор

Maam in line no 29, if we remove the space or double quotation..then why it is giving us output as integer values?

neelimajaiswal
Автор

please explain in reverse of i/p - a2b3c1 O/P- aabbbc

amanchaudhary
Автор

The way of explanation is really so good madam could u make vedeos on java interview qusstikns to crack the interview please make it madam.

rachamallidorasrivignesh
Автор

hash map does not follow the insertion order right?

vijaykumar-utze
Автор

Input is String str="AAAABBBCCA" output : A=4 B=3 C=2 A=1 (Ask this program recent interview) pls provide solution

rakhamajighagare
Автор

public class Test {

public static void main(String[] args) {
String s ="ABBCCCDDDD";
int n = s.length();
// A1B2C3D4
int count=1;
Map<Character, Integer> map = new LinkedHashMap<Character, Integer>();

for(int i=0 ; i<n ; i++)
{
char ch =s.charAt(i);
if(!map.containsKey(ch))
{
map.put(ch, count);
}else
{
map.put(ch, map.get(ch)+1);
}
}

for(char z : map.keySet())
{
if(z>1)
{

}
}

}

}

shivarajyadachi
Автор

This solution will not work if we have repeating characters ex: aabbcccaadd -> a2b2c3a2d2. But great explnation

tmsdeepak