public class NoOfConsAlphabet {
public static void main(String[] args) {
String str="aaabbddaabbcc";
int count=1;
String finalString="";
for(int i=1;i<str.length()-1;i++)
{
if(str.charAt(i)==str.charAt(i+1))
{
++count;
}
else
{
finalString+=str.charAt(i)+count+",";
count=1;
}
}
System.out.println(finalString);
}
}
I am getting this as my o/p:99,100,102,99,100, Can someone tell me how to get this resolved not sure what this is?Need to get an output of a3,b2,d2,a2,b2,