Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:43:51+00:00 2026-06-09T13:43:51+00:00

I am stuck splitting a string into pieces to store the pieces into an

  • 0

I am stuck splitting a string into pieces to store the pieces into an ArrayList. I can split the string onto " ", but I’d like to split the string onto "farmersmarket" and store it into an Arraylist. To be able to return one of the indexed pieces of string.

    ArrayList<String> indexes = new ArrayList<String>();
    String s = file; 

    for(String substring: s.split(" ")){
        indexes.add(substring);
        }
    System.out.println(indexes.get(2));

Any ideas to split a string on "farmersmarket"?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:43:53+00:00Added an answer on June 9, 2026 at 1:43 pm
    String[] tokens = yourString.split("farmersmarket");
    

    And afterwards you don’t need an Arraylist to get a specific element of the tokens. You can access every token like this

    String firstToken = tokens[0];
    String secondToken = tokens[1];
    

    If you need a List you can do

    List<String> list = Arrays.asList(tokens);
    

    and if it has to be an Arraylist do

    ArrayList<String> list = new ArrayList<String>(Arrays.asList(tokens));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this <name>sekar</name> . I want to split this string
Im stuck with this little project in C# but basically my problem is this:
I am wondering if I am going about splitting a string on a .
i am confused on why it doest not split the string? my array of
I've got a string that I'm splitting, as follows: foo, bar, baz, etc =
I am having problems with 'splitting' a larger list into several of it's combinations.
Good programming practice these days tends to mean splitting your stuff up into lots
I am stuck at a place where i am able to proceed with a
Instead of splitting each permission into individual columns or sql server table we are
Surprisingly simple/stupid/basic question, but I have no idea: Suppose I want to return the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.