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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:08:20+00:00 2026-06-15T14:08:20+00:00

Android 2.3.3 This is my code… String[] expression = {}; //globally declared as empty

  • 0

Android 2.3.3

This is my code…

String[] expression = {""}; //globally declared as empty

somewhere in the code below, I am trying to assign a string to it.

expression[0] = "Hi";

I keep getting the following error...
12-08 22:12:19.063: E/AndroidRuntime(405): java.lang.ArrayIndexOutOfBoundsException

Can someone help me with this..
Can we access the index 0, directly as i am doing?

Actual Code :::

static int x = 0; // global declaration
String[] assembledArray = {""}; // global declaration

assembleArray(strSubString, expression.charAt(i)); //Passing string to the method

//Method Implementation
private void assembleArray(String strSubString, char charAt) {
        // TODO Auto-generated method stub

        assembledArray[x] = strSubString;
        assembledArray[x+1] = String.valueOf(charAt);
        x = x+2;

    }
  • 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-15T14:08:22+00:00Added an answer on June 15, 2026 at 2:08 pm

    The problem is not in assembledArray[x]; it’s in assembledArray[x+1].

    At the first iteration, x+1 = 1, so you cannot access that part of the array. I would suggest using a dynamic array, aka an ArrayList:

    ArrayList<String> assembledArray = new ArrayList<String>(); // global declaration
    
    assembleArray(strSubString, expression.charAt(i)); //Passing string to the method
    
    //Method Implementation
    private void assembleArray(String strSubString, char charAt) {
        assembledArray.add(strSubString);
        assembledArray.add(String.valueOf(charAt));
    }
    

    This way, Java takes care of the resizing, and you don’t need to keep track of x.

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

Sidebar

Related Questions

I am using this code for on android just trying to convert string to
I have this code in Android: Map<String, String> idObject1 = new LinkedHashMap<String, String>(); idObject1.put(Id,
I am sending dtmf tone via this code. String number=tel:+962791212121,2,3,3; Intent c1= new Intent(android.content.Intent.ACTION_CALL,
I'm trying to launch Developer apps from my Android app with this code: final
I'm trying to decrypt an encrypted image in Android using this code: public class
I write code for finding the Android version like this String version=Build.VERSION.RELEASE; by using
I'm trying to save a sound as a ringtone in Android using this code.
I was trying to get the screen resolution of android phones,using this code DisplayMetrics
I have this code on my Android phone. URI uri = new URI(url); HttpPost
I used this code in my Android application: import org.apache.http.client.methods.HttpPost; ... HttpClient httpclient =

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.