I am trying to format a specific string. I had the unfortunate event of my laptop crashing on me the other day, taking away with it lots of valuable code. I did save most of the files, but the few that weren't saved were crucial to my android app. Well Here is my code that tries to format a string. I need all the numbers at the beginning of each line to go away. there are about 3600 of them.
//inside onCreate method
String string = "3 import android.animation.Animator; \n" +
"4 import android.animation.AnimatorListenerAdapter; \n" +
"5 import android.animation.ValueAnimator; \n" +
"6 import android.app.Activity; \n" +
"7 import android.content.Context; \n" +
"8 import android.content.DialogInterface; \n";
char[] ch = string.toCharArray();
char c ='M';
for(int i=4;i<ch.length;i++){
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;
boolean b4 = false;
c = ch[i];
if((c >= '0' && c <= '9') && (ch[i-1]=='\n')){
b1 = true;
if((ch[i+1] >= '0' && ch[i+1] <= '9'))b2=true;
if((ch[i+2] >= '0' && ch[i+2] <= '9'))b3=true;}
if(b1)ch[i]='Q';
if(b2)ch[i+1]='Q';
if(b3)ch[i+2]='Q';
b1 = false;
b2 = false;
b3 = false;
}
String strings = ch.toString();
strings.replace("Q","");
Log.d("meoww","juy "+strings);
As you can see, the for loop tries to get rid of these numbers for me. The logs show the following output:
juy [C@3d03b1f5
I know its probably a minor error, but how can I correct this. Like I say, I will have to do this about 3600 inside this for loop.
thanks for any suggestions,
Keep on coding
String.valueOf()instead of toString()[C@3d03b1f5that means it's displaying the address of the object and not the contents inside...just sayingString strings = new String(ch);instead ofString strings = ch.toString();