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.
精彩评论