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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:43:45+00:00 2026-06-04T07:43:45+00:00

Hello again stackoverflow, I have a question concerning List of Objects. I have tried

  • 0

Hello again stackoverflow,
I have a question concerning List of Objects.

I have tried out writing some things, but can’t find it though.
How do I find an Object in a list of objects, when these objects are lists of its own?

this is what i have so far:

Recipe is a List of: {modification[], ingredients[], recipeBookName, recipeName}

public void removeFromBook(Recipe recipeName) {
    recipes = getRecipes();
    emptyRecipe = getEmptyPage(recipeBookName);

Now, I want to replace a Recipe which has a recipeName, by the emptyRecipe.
I think it will be something like:

for(r in recipes) {
    if(r.recipeName == recipeName) {
        list.replace(Recipe, emptyRecipe)
    } else {

    }
}

any ideas? 🙂

here’s my constructor for the Recipe class:

    public String[] modifications;
public String[] ingredients;
public String recipeName;
public String partOfRecipeBook;

public Recipe(String recipeName, String[] modifications, String[] ingredients, String recipeBookName){
    setRecipeModifications(modifications);
    setRecipeIngredients(ingredients);
    setRecipeName(recipeName);
    setRecipeBookName(recipeBookName);
}
  • 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-04T07:43:46+00:00Added an answer on June 4, 2026 at 7:43 am

    Using a List with Objects in it (of which some are arrays) is not the best way it would be better to define a new object Recipe and use that.

    public class Recipe {
        private List<Ingredient> ingredients;
        private List<Modification> modifications;
        private String bookName;
        private String book;
    }
    

    Then replacing in ingredients is a lot simpler. e.g. give recipe a function like

    public void replaceIngredent(Ingredient oldIngredient, Ingredient newIngredient) {
        int index = ingredients.indexOf(oldIngredient);
        if (index != -1) {
            ingredients.remove(index);
            ingredients.add(index, newIngredient);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to
Hello again stackoverflow... Once again I have a troublesome problem. I have a page
Hello again; i need to show X,Y,Risk in ListBoxes. But i can not do
Hello guys and sorry for such a long question, but... I have a C#
Hello I've runned in to a problem again that I can't solve on my
I know this sounds like a broad question but I can narrow it down
Hello again great knowledge masters of stackoverflow, once again the small coder apprentice tabaluga
Hello stackoverflow pals.I am a new rails learner. My question is: I am listing
Hello again dearest Experts, I have an ecommerce site at http://www.millenniumhealthproducts.com The site was
Hello Again my fellow programmers out there, I'm designing and programming from scratch a

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.