Question: java code level: beginner write a method strToList() public static ArrayList strToList(String word) This method transforms a String into an ArrayList containing each character of

java code

level: beginner

write a method

strToList()

public static ArrayList strToList(String word)

This method transforms a String into an ArrayList containing each character of the string in order.

For example, strToWord("word") will return an ArrayList of four characters: {w,o,r,d} .

strToWord("hello CSE8B") will return an

ArrayList: {h,e,l,l,o, ,C,S,E,8,B}

  • Return an empty list if the string is empty.
  • Return null if the string is null
  • Think about base case.
    • When should the method terminate/end?
    • Under what condition should your method stop making recursive calls and return your expected value?
  • Think about the recursive case
    • Make recursive calls to the method; make sure to call to strToList
      • How would the input have to change in the recursive call?
      • Keep in mind, you do not need to keep the original ArrayList content.
  • An iterative solution will not be accepted.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!