Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spliting a String from a particular character

 
abhinas raj
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to split a String from a particular character please some one write the code how to do that

String str1="city-state";

i wnat "city" and "state" to be stored in two different seperate variable. like in str2 and str3 how to do that .
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, nobody is going to write that code for you, nor should they. Beside the fact that JavaRanch is NotACodeMill (<- click) this sort of thing is very important to master yourself. Especially considering the forum you posted this in. If you take a look at the String API, under Method Summary, you should be able to find a method that will allow you to do what you're looking for. Let's start by identifying that method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic