Handling multiple string using REGEX in java [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
开发者_开发技巧Closed 9 years ago.
Improve this questionI have 5 strings "a,b,c,d,e" in a drop down,i am writing a testcase where i am checking if the user has selected any of the five then insert into DB,currently i am not getting any of the values from client side,so it has to be written in a junit if the user has selected any of these values then return true .
current approach: 1st method having 'a' data JSONObject obj=new JSONObject(); obj.put("DT",a);
2nd method having 'b' data JSONObject obj=new JSONObject(); obj.put("DT",b);
and so on for furthur values.which is creating more number of methods.I need to insert all the values in a single method.
Thanks
I'm a bit confused as to what you're actually struggling with. Are you just looking for a helper method to do this?
public static JSONObject createAndPopulateObject(String data) {
JSONObject obj = new JSONObject();
obj.put("DT", data);
return obj;
}
//...
aObj = createAndPopulateObject("a");
bObj = createAndPopulateObject("b");
精彩评论