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 9236175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:13:33+00:00 2026-06-18T07:13:33+00:00

how do I split arrayList String SCHOOLWORK BALCONY INSIST SALTPETER BOLTON KITSCHY CLIENTELE I

  • 0

how do I split arrayList String
SCHOOLWORK
BALCONY
INSIST
SALTPETER
BOLTON
KITSCHY
CLIENTELE

I want to split those words to “SCH”, “OOL”, “WO”, “RK”.

Here is my code

import java.io.File;
import java.util.ArrayList;

public class HW2 {

    public static ArrayList<String> getTiles(ArrayList<String> input_list_of_strings) {
        // create a substring by go through the loop first, then .... (instruction)
        Object[] subString = new Object[input_list_of_strings.size()];
        for (int i = 0; i < input_list_of_strings.size(); i++) {
            subString[i] = input_list_of_strings.get(i);
            // test just want to see if subString get all String
//          System.out.println(subString[i]);

            String delim=" ";
            String[] splitstrings = ((String) subString[i]).split(delim);
            for (int j = 0; j < splitstrings.length; j++) {
                splitstrings[j] +=delim;
                System.out.println(splitstrings[j]);
            }
        }
        return input_list_of_strings;       
        }


    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ArrayList<String> input_words = new ArrayList<String>();
        input_words.add("SCHOOLWORK");
        input_words.add("BALCONY");
        input_words.add("INSIST");
        input_words.add("SALTPETER");
        input_words.add("BOLTON");
        input_words.add("KITSCHY");
        input_words.add("CLIENTELE");
        System.out.print(getTiles(input_words));    
    }

}

Thank you…

  • 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-18T07:13:35+00:00Added an answer on June 18, 2026 at 7:13 am

    I would use an interface to encapsulate how you want to split each string.

    public static interface StringSplitter {
        public List<String> splitString(String s);
    }
    

    Then your ‘getTiles’ method would simply be:

    public static ArrayList<String> getTiles(ArrayList<String> input,StringSplitter splitter) {
    
        int initSize = input.size();
        for(int i = 0; i < initSize; i++) {
    
            String source = input.remove(0); //Remove from head
            input.addAll(splitter.splitString(source)); //Add to end
    
        }
    
        return input;
    
    }
    

    NOTE: This method modifies the original list, it can be easily adapted to simply copy the list if need be. Although, I like it better this way.

    Since the exact process for splitting these words is unclear, I am going to guess that you want to keep splitting a word by three characters, unless that would leave only one character, then split by two – else don’t split. So your default ‘StringSplitter’ would be:

    public static final StringSplitter DEFAULT_SPLITTER = new StringSplitter() {
    
        @Override
        public List<String> splitString(String s) {
            List<String> subs = new ArrayList();
            while(!s.isEmpty()){
                int splitsize = 0;
                if(s.length() < 5) {
                    if(s.length() == 4) {
                        splitsize = 2;
                    } else {
                        splitsize = s.length();
                    }
                } else {
                    splitsize = 3;
                }
                subs.add(s.substring(0,splitsize));
                s = s.substring(splitsize);
            }
            return subs;
        }
    
    
    };
    

    Your main method would then be:

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ArrayList<String> input_words = new ArrayList<String>();
        input_words.add("SCHOOLWORK");
        input_words.add("BALCONY");
        input_words.add("INSIST");
        input_words.add("SALTPETER");
        input_words.add("BOLTON");
        input_words.add("KITSCHY");
        input_words.add("CLIENTELE");
        System.out.print(getTiles(input_words),DEFAULT_SPLITTER); //Make sure to use DEFAULT_SPLITTER
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList of Timestamps. I want to split this ArrayList into several
List<String[]> list = new ArrayList<String[]>(); String str = a b c; list.add(str.split( )); Basically
I want to split a string in C#.NET that looks like this: string Letters
Here i have this type of String and i want to split this string
{ ArrayList<String> node_array = new ArrayList<String>(); String allValues[] = node.split([(,)]); for(String value : allValues){
I want to using regex on Java to split a number string. I using
I have a string which has say 3000 characters, now I want to split
I want to split a string like p^q into two strings, i.e. p and
I have a string like this: Name foo Modified bar I want to split
I am writing a program where I want to split a string separated by

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.