Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to seperate strings

Status
Not open for further replies.

MSB18

Programmer
Nov 2, 2001
5
GB
Help!!!!!!!!!!!!!!!!

Can anyone help me with my problem, i need to seperate a string e.g. ABCDEFG, after the second character. Bearing in mind the string is from a user input, how to i locate the position of seperation and how seperate it into two variables?


Thank you in advance

MSB18
 
String s = "ABCDEFG";

String begin = s.substring(0, 2);
String end = s.substring(2, s.length());

//Then, you have:

begin = "AB"
end = "CDEFG"

Hope this helps :) ------
KJR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top