about | help | code help+videos | done | prefs |
apcsaListFindTarget
Given an ArrayList of Strings and a target String, return an ArrayList of String values which only has entries containing the target String in them somewhere. Try doing this problem first with an indexed for loop using the remove() method of ArrayList. After you solve that, try reversing the direction of the loop control variable. After you solve it a second time, try it again using an enhanced for (a.k.a. a for-each) loop. FYIThe data type of the output is List<String> just because CodingBat does not allow the creation of methods with a return type of ArrayList<String>. Because an ArrayList is-a List, you can safely pretend that the return type is ArrayList<String> instead of trying to create something called a List. The AP CSA curriculum used to require that students know what a List is (an interface), but no longer requires that knowledge. apcsaListFindTarget(["out of time and out of", "darkness", "sometimes will occur", "the light"], "me") → ["out of time and out of", "sometimes will occur"] apcsaListFindTarget(["hey ho", "ha ha", "har har", "the Hardy boys"], "ha") → ["ha ha", "har har"] apcsaListFindTarget(["start", "middle", "end"], "e") → ["middle", "end"] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 220
Copyright Nick Parlante 2017 - privacy