How do I create a method header that takes a string as an argument and returns the characters in the argument as a set. Please only reply if you know the answer. Thanks.

public class Food
  private TreeSet<String> myList = new TreeSet<String>();  

  public Food()
     myList = new TreeSet<String>();

  public String shoppingList(String aFood)
     return //   
7 Years
Discussion Span
Last Post by ttboy04

Thank you JamesCherrill - Where do I put this. I have done this so far

public Set<Food> toLetterSet(String aFood)
   return;  // error message is missing return value tried to put arg but got further error msg? 

Edited by ttboy04: n/a


Forum rules say I can't write your code for you, but here are some hints:
the method header says you will return an object of type Set<Food>
So somewhere in your method you need to declare one, populate it with zero or more Food objects, then return it in the return staement.
I have no idea how we got from characters to Food - what's your REAL question?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.