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);
}
List<List<Object>>, and eachList<Object>is aRecipelist? UsingList<Object>isn't really taking advantage of generics at all. Can you show us a little more code (like how you add objects to the list, what objects you make, etc.)java.util.List, do you?recipes?Recipe is a List of: {modification[], ingredients[], recipeBookName, recipeName}that does not sound right. I don't think you should use a list for storing the different things, but define your own class which has dedicated members for the modifications, ingredients and so on