about | help | code help+videos | done | prefs |
Given a String input str with length > 0, return an ArrayList of all the characters in the String, as single-character Strings in the order they were encountered in the original. The output must have no repeats, meaning that if a character occurs more than once in the input it will only occur once in the output, based on the first time it appears in the input. 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. HINTYou will need a loop for this. Also remember to declare and instantiate (and return) a new ArrayList. Also, the ArrayList class has a handy method called contains() (not tested on the AP CSA exam, nor is the List interface) which can save you from having to use a nested loop. Neat! apcsaListJustCharacters("hi") → ["h", "i"] apcsaListJustCharacters("Hello") → ["H", "e", "l", "o"] apcsaListJustCharacters("a man a plan a canal panama") → ["a", " ", "m", "n", "p", "l", "c"] ...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: 240
Copyright Nick Parlante 2017 - privacy