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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:23:44+00:00 2026-05-28T14:23:44+00:00

Im having a bit of a problem with this code each time i execute

  • 0

Im having a bit of a problem with this code each time i execute it it gives me an error
String index out of range: ‘n’
n – is the no. of characters that is entered in the textbox pertaining to this code…
(that is textbox – t2.)it is stuck at that first textbox checking it does not go over to the next as mentioned in the array.

Object c1[] = { t2.getText(), t3.getText(), t4.getText() };    
String b;
String f;
int counter = 0;
int d;
for(int i =0;i<=2;i++)
{
    b = c1[i].toString();
    for(int j=0;j<=b.length();j++)
    {
        d = (int)b.charAt(j);
        if((d<65 || d>90)||(d<97 || d>122))
        {
            counter++;
        }
    }
}

it is basically a validation code that i am trying to do without exceptions and stuff(still in the process of learning 🙂 )

any help would be appreciated
thx very much.

  • 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-05-28T14:23:45+00:00Added an answer on May 28, 2026 at 2:23 pm

    Use <, not <= when iterating over the string. With <=, you get an out of bounds error, when j equals the length of the string. Remember that characters in the string are indexed starting from zero.

    for(int j = 0; j < b.length(); j++)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of a problem with this code. The program gives me
I'm having a problem with T4MVC losing the code it generated each time I
Having a bit of a problem, Due to the source-control set-up we use, each
I'm having a bit of a problem using FieldOffset correctly with arrays. The code
I'm having a bit of a problem figuring out how to get the X/Y
I'm having a bit of a problem with this. I wanted to make a
Having a bit of a problem creating an instance of an object. Bear in
I am having a bit of a problem. I get a RAW char* buffer
I'm having a bit of a problem. I have a datatable in the parent
I'm having a bit of a problem with converting the result of a MySQL

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.