开发者

Java method to get back parameters from string

开发者 https://www.devze.com 2023-04-04 06:10 出处:网络
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开发

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

精彩评论

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