开发者

Java method to get back parameters from string

I have a string like following

   Integer-Integer_Integre_Integer.....

For eg.

   3-1_0_2_4

I want to extract everything on the left side of - into one variable and everything on the right side of开发者_开发问答 - into another variable

String s1 = 3;
String s2 = 1_0_2_4....


String[] parts = "3-1_0_2_4".split("-");

String s1 = parts[0];
String s2 = parts[1];


Simple, use String.split(...). I'll leave the rest to you. IMHO, next time just look at the javadoc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜