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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:53:04+00:00 2026-06-03T02:53:04+00:00

I have created a VF page with 2 button 1 for add inputtext 1

  • 0

I have created a VF page with 2 button 1 for add inputtext 1 by 1 and 2nd to delete inputtext 1 by 1.
The process is working 1 am bale to add and delete. But when it came to last inputtext it through’s an error. For eg: If added 3 inputtext 1,2,3
I am able to delete 3,2 but when i delete 1st when it through’s an error
List index out of bounds: 1

here is my code

public PageReference cancel() {

system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew Out ' + eqLstNew.size());
integer i =0;
  if( i<eqLstNew.size()){
    i++;
    system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew 1st ' + eqLstNew.size());
    system.debug('@@@@@@@@@@@@@@@@@@@ i size ' + i);
    eqLstNew.remove(i);

  }
  return null;
}

can anybody find the solution and tell me what is wrong in the code.

Thanks
Anu

  • 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-03T02:53:05+00:00Added an answer on June 3, 2026 at 2:53 am

    Make the i++ call at the end of the if:

    public PageReference cancel() {
    system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew Out ' + eqLstNew.size());
    integer i =0;
      if( i<eqLstNew.size()){
        system.debug('@@@@@@@@@@@@@@@@@@@ eqLstNew 1st ' + eqLstNew.size());
        system.debug('@@@@@@@@@@@@@@@@@@@ i size ' + i);
        eqLstNew.remove(i);
        i++;
      }
      return null;
    }
    

    But I don’t understand why you are using a variable for this. If you always want to return the first element you should write it like this. Using an extra variable (which always has the same value) makes it more complicated.

    public PageReference cancel() {
      if(eqLstNew.size() > 0){
        eqLstNew.remove(0);
      }
      return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with sencha to build mobile app. I have created one page
I have created a signup page on my site, but the javascript validation function
I have a WordPress blog on my website. But I've created my own page
I have created a greasemonkey script for the purpose of: Add print receipt button
I have created a page on my site where users can post directly to
I have created login page forced login in several pages. Now i need to
I have created a page with a static image positioned to the ride side
So, I have created a page with 3 frames, top, left and right where
I have created one aspx Page from that i need to access the property
I have created a web page (ASP.NET) that includes a stylesheet to mimic Dynamics

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.