public static void main(String[] args) {
// TODO Auto-generated method stub
String str="aaabbddaabbcc";
String[] str2=str.split("");
String pointer=str2[0];
int count=0;
String finalStr="";
for(String str132:str2)
{
if(str132.equalsIgnoreCase(pointer))
{
++count;
}
else
{
finalStr+=str132+count;
count=0;
pointer=str132;
++count;
}
}
System.out.println(finalStr);
}
On performing a str.split("")
, why am I getting a ""
in the 0th index of the str2
array?