I'm storing a string in a database with a value such as "020734". I would like to be able to pull the string apart.
I have:
String values = "020734";
I need:
String values = "020734";
String value1 = "02";
String value2 = "07";
String value3 = "34";
Could you guys possibly point me in a general direction?
Erm, how about value1 = values.substring(0, 2); value2 = values.substring(2,4)
...etc? That will get you two characters at a time from the string.
checkout String.substring
.
String values = "020734";
String value1 = values.substring(0, 2);
String value2 = values.substring(2, 4);
String value3 = values.substring(4, 6);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With