I have an object (Object 1 for reference) which contains an arraylist of another object (Object 2 for reference).
I want to include a method in Object1, which will take a search term as a parameter and will then iterate through the arraylist of objects2. Through every iteration, it will need to compare the search term against every variable the object has (It has 5 different variable). For example :
The user inputs a search term, the system will then iterate through the arraylists of objects. The first object in the arraylist, it will compare the 5 String variables of that object with the search term, and if there is a single match, it will print that object. It will then move on to the second object in the array list and do the same...
I'm not quite sure how to implement this in a nice readable way. The only way I can think of is implementing multiple IF OR OR statements...
Any ideas ? Any help is appreciated, thanks!
List<List<String>> listOfLists = new ArrayList<List<String>>();if not atleast mention the structure of your arraylistpublic boolean containsText(String key)method that does the checking for you. Then when you iterate through the ArrayList, call this method.