开发者

Handling multiple string using REGEX in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

开发者_开发技巧

Closed 9 years ago.

Improve this question

I 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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜