java - android change first blank to "AA" -
change first blank "aa"
string = "a b c";
change
string = "aaab c";
the answer clear
a = a.replacefirst(" ", "aa");
try code,you may got expected answer,
string str="a b c"; boolean a1 = true ; stringbuilder strbu = new stringbuilder(); for(int i=0 ; i<str.length();i++) { character b = str.charat(i); if(b.equals(' ') && a1 == true ) { a1 = false; strbu = strbu.append("aa"); } else { strbu = strbu.append(b); } } log.e("str","string:"+strbu.tostring());
Comments
Post a Comment