id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-lists > apcsaListJustCharacters
prev  |  next  |  chance

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.

FYI
The 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.
HINT
You 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)

public List<String> apcsaListJustCharacters(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 240

Copyright Nick Parlante 2017 - privacy