I am working on a application where I have to deal with a custom variable aVar
-
String aVar = price/barcode/area1/true // varName/varType/varScope/tracable
There may be some other attribute added to aVar
seperated by a ('/').
To get varName, varType, varScope
etc I have to do the following things, please see the code below -
String[] token = aVar.split("/");
String varName = token[0];
String varType = token[1];
String varScope = token[2];
String traceable = token[3];
Here you can see the varName
is taken from token[0]
which is price
, varType
is taken from token[1]
which is 'barcode' and so on. Here I am assuming - after splitting varName
always be in token[0], varType
always be in token[1] and so on.
Now my question is that - Does the String
array returned by the split()
method always contain the String
token in a order by which they are appeared (price-->barcode-->area1-->true)?
I have tested this several times with some few input and found the order maintained. But I am not sure will it be ALWAYS true for a VERY LONG string.
String.split
accepting achar
. Do you meanaVar.split("/")
? – Jon Skeet Jan 28 at 7:08