i have this String and i want to store each part is individual
String s="PN:VYZ,CPU:45,MEM:24,IO:93,CPU:39,MEM:2,IO:83,CPU:17,MEM:-2,IO:65,CPU:41,MEM:9";
like this :
pn
="VYZ"
cpu0
=45
MEM0
=24
IO0
=93
CPU1
=39
... and so on
Try as follows
class Demo{
public static void main (String args[]){
String x = "PN:VYZ,CPU:45,MEM:24,IO:93,CPU:39,MEM:2,IO:83,CPU:17,MEM:-2,IO:65,CPU:41,MEM:9";
String []arr = x.split(",");
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}