Suppose there is a line from the xml file:

<Item name="название" image="Картинка" id="id" ItemsCraft="33:44:24:0:55:0:22:66:77" price="цена"/> 

I am interested in the attributes ItemsCraft="33:44:24:0:55:0:22:66:77" How to take each number through the colon into a separate change, thereby disassemble it? It is clear that you can do it by stupid and just like this:

 ItemCraft1 ="33" ItemCraft2 ="44" ItemCraft3 ="24" ItemCraft4 ="0" ItemCraft5 ="55" ItemCraft6 ="0" ItemCraft7 ="22" ItemCraft8 ="66" ItemCraft9 ="77" 

This is not correct and cumbersome. Hmm ... split(); ...

  • 2
    Why in a separate? Wouldn't it be wiser to use the list? - Sergey Gornostaev

1 answer 1

split(); method split(); decided everything. The question is closed.

 String str1 = "33:44:24:0:55:0:22:66:77"; String[] str2; str2 = str1.split(":"); for(String _string : str2){ System.out.println(_string); }