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.

HINT
You will need a loop for this. Also remember to declare and instantiate (and return) a new ArrayList. Also, the List interface has a handy method called contains() 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