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()
   {
     super();
     myList = new TreeSet<String>();
   }

  public String shoppingList(String aFood)
  {
     return //   
  }
}

Recommended Answers

All 4 Replies

Set<Character> myMethod(String arg)

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? 
 }

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?

appericate your time, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.