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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:58:40+00:00 2026-06-17T03:58:40+00:00

I am just trying to split a string into two smaller strings. It seems

  • 0

I am just trying to split a string into two smaller strings. It seems like it would be easy but for some reason I cannot figure it out. An example of what I am trying to split is this:

AA
BB
DD
FF
TT
EE
SE
GR

These values are currently in an ArrayList and I would like them to split into two arraylists

A                A
B                B
D                D

I tried this

prse = calls.get(t).split(""); //also tried prse = calls.get(t).split("", -1);
            call1.add(prse[0]);
            call2.add(prse[1]);

But it filled my arraylists with empty characters. (Printed []
[, ]
[, , ]
[, , , ]
[, , , , ])

So then I tried

    String split = calls.get(t).substring(0,1); //This is 285 that is puking
    String split2 = calls.get(t).substring(1,2);
                System.out.println(split);
                call1.add(split);
                System.out.println("1: " + call1);
                call2.add(split2);
                System.out.println("2: " + call2);

Which works up to a point but then dies a horrible death:

1: [F, P, T, B, F, D, S, G, G, G, Z, S, Q, E, F, H, L, P, O, L, G, B, V, F, W, Q, T, H, G, E, R, T, Y, C, G, D, C, H, C, A]
2: [o, G, U, U, Y, Y, T, T, T, T, T, R, E, S, G, J, H, C, H, H, H, G, C, J, H, D, G, J, H, D, R, G, V, C, G, V, V, D, V, V]

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
        at java.lang.String.substring(String.java:1946)
        at print.Reader.ffy(Reader.java:285)
        at print2.Print2.main(Print2.java:48)

Can anyone suggest a better way to do this (Or explain to me what I am doing wrong)?
Notes:
I would like to put the split letters into their own, separate ArrayList String (due to later usage.) so I would rather not charArray.

  • 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-17T03:58:42+00:00Added an answer on June 17, 2026 at 3:58 am
            prse = calls.get(t).split("");
            call1.add(prse[0]);
            call2.add(prse[1]);
    

    when u split with blank string => “”, the first string that u get is blank(“”).
    so example : “AB” prse[0] = “”, prse[1]=”A” ,prse[2]=”B”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to split up an input string into smaller strings delineated by
I'm trying to split up a string into two parts using regex. The string
I'm trying to compare two strings and as output I would like a count
I am trying to split a Unicode string into words (simplistic), like this: print
So I'm trying to split just a string I've read in through a csv
I'm trying to split up a nucleotide sequence into amino acid strings using a
Im trying to split a String into an Array. In PHP I normally use
im trying to split a string but keep the delimiter at the beginning of
i'm trying to use php to split a string into array components using either
so I'm trying to split a string like 19 01 23 75 03 34

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.