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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:55:50+00:00 2026-06-04T01:55:50+00:00

I have static ArrayList<Batch> . i want to remove which object contain productcode This

  • 0

I have static ArrayList<Batch>. i want to remove which object contain productcode

This is my Batch Entity

public class BatchControl implements Parcelable{
  private String productCode;
  private String lotNumber;
  private String batchSerialNumber;
  private double quantity   ;
  private int sequence;
  private String productName;
  private String type;
  //Setter & getter
 }

This is my removing object

  static ArrayList<String> lstString = new ArrayList<String>();
  for (Iterator<Batch> i = lstString.iterator(); i.hasNext(); ) {
        Batch value=(Batch )i.next();
        if(value.getSequence() == iVal) {
            lstString.remove(value);
        }
    }

iVal is Android TableLayout contain the row number.

        String number = txtNumber.getText().toString();
    iVal = Integer.parseInt(number);

But it didn’t remove which object have iValue. Because of the resoan static arraylist so, each & every time when i remove size going to change.

Please help me out.

Thanks in advance.

  • 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-04T01:55:52+00:00Added an answer on June 4, 2026 at 1:55 am

    When using an Iterator on a list, you can safely remove the current element (regarding position or index in the list) with Iterator.remove().

    for (Iterator<Batch> i = lstString.iterator(); i.hasNext(); ) {
        Batch value=(Batch )i.next();
        if(lstBatCtrl.get(k).getSequence() == iVal) {
            i.remove();
        }
    }
    

    Take into account that using remove() on a static List can yield to problems if there are concurrent modifications on the List. Citing Iterator.remove()‘s javadoc:

    The behavior of an iterator is unspecified if the underlying
    collection is modified while the iteration is in progress in any way
    other than by calling this method

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

Sidebar

Related Questions

I have created a JSON object like this: static ArrayList<item> list = new ArrayList<item>();
I have a class and this class has one public element ArrayList myList.(I have
I have the following code: public class TestSynch extends Activity { public static ArrayList<HashMap<String,String>>
I have a class like this public class StockCodes { public static boolean loaded
I intended to create a class which only have static members and static functions.
public class driver { private static ArrayList<String> arrayList ; TownBankRecord TBR = new TownBankRecord();
i have this code: static ArrayList<Integer> output_list = new ArrayList<Integer>(); static ArrayList<Integer> pair_list =
I have a Arraylist, which i want to save in a file for use
Hello I have written a such function under Eclipse: public static ArrayList<String> getMails(){ ArrayList<String>
I have this class: public class User { public User(String nickname, String ipAddress) {

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.