I have field type string that can get two type of values on it:
Now I have 2 questions:
just use split operation and check length.
String[] prop = strprop.split("/");
if(prop.length > 1){
String El = prop[prop.length];
String El0 = prop[prop.length-1];
}
To answer 1) I would use (assuming variable str
contains your value):
str.contains("/"); // If true => complex type
For 2):
String[] vals = str.split("/");
String lastVal = vals[vals.length-1];
String preLastVal = vals[vals.length-2];
Please note that you should check for array length before trying to get the values, otherwise you're likely to get an ArrayIndexOutOfBoundsException.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.