Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - int[] tostring后如何变回整型数组
int[] tostring后如何变回整型数组
你这个数组是怎么toString的呢?

以下为演示代码,未经过测试int[] a =....;

string buffer buf = new string buffer();

for(int I = ;我& lta .长度;i++)

buf . append(integer . tostring(a[I]))。追加(',');

反过来就是

int count = ;

String s = buf . tostring();

for(int I = ;我& lts.length()。i++)

if( s.charAt(i)== ',')count++;

int[]b = new int[count];

int p1=,p2 = ;

int I = ;while((p2=s.indexOf(','))& gt= ){

b[I]= integer . parse int(s . substring(P1,p2));

p1 = p2

}