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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:35:01+00:00 2026-06-05T06:35:01+00:00

I have a vector that I am trying to remove an object from. The

  • 0

I have a vector that I am trying to remove an object from. The Method is stated below (as well as the check to insure it is removed). In it calls the getVector Method that defines where the vector is stored, and findItem which returns an object inside the Vector. I know getVector and findItem work correctly due to me being able to add an object to a vector, and view objects in the vector.

public Message removeMember (Message m)

    //list is the vector location
    //item is the object in the vector i am looking to remove
{
    list = getVector(m);
    item = findItem(list, m);

    if (item != null) // if item exists in the vector (code enters this statement)
    {
        System.out.println("removing " + item.name + " from file");
        list.remove(item);  // remove the item from the vector
        // search for item to insure it is removed
        item = findItem(list, m);
        if (item == null) // if item has been removed
        {
            System.out.println(m.name + " removed from file.");
            m.response = m.name + " removed from file.";
        }
        else  //if the item has not been removed
        {
            System.out.println("Error removing member from file.");
            m.response = "Error removing member from file.";
        }
    }
    else  // item does not exist in vector at all
    {
        m.response = m.name + " was previously removed or never existed.";
    }
    return m;
}

The problem I am experiencing is that even though I do the check to make sure the item is removed, and the program enters that check and the System.out.println(m.name + ” removed from file.”) verifies on the console that the entry has been removed, I can still search for it (through the program) and when I open the vector location, browse the text file, I can see the information is still in the file.

Thank you in advance for your help!

  • 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-05T06:35:02+00:00Added an answer on June 5, 2026 at 6:35 am

    Unless i’m missing something, you never actually remove anything from a file. I assume you’re writing the Vector’s elements to a file somewhere else in your code. Removing an element from the Vector itself will not remove it from the file; you must rewrite the file.

    If you’re saving the Vector as a serialized object and attempting to view it in notepad, you still need to rewrite the file with the new Vector object after removing the desired element.

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

Sidebar

Related Questions

I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
I have a vector object that contains clipboard data. I am trying to write
I'm trying to create a generic function that removes duplicates from an std::vector. Since
I have a vector that I fill with pointers to objects. I am trying
I have a Vector that holds a number of objects. My code uses a
I have a vector that holds pointers to abstract type Rock : vector<Rock*> rocks;
I have a vector X that contains positive numbers that I want to bin/discretize.
I have a vector of beans that holds information I want to display in
I have a sparsely populated vector that I populated via hashing, so elements are
I have a vector in R that looks like this: dat <- c(TRUE, TRUE,

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.