Well, turingmachine completely ignored the question.
Just return an empty list
return new LinkedList<names>();
or you could also define an empty list class constant to use for that purpose
public final static LinkedList<names> EMPTY_LIST = new LinkedList<names>();
A couple of additional thoughts:
- Do you really need to return a LinkedList? It's usually better to use the interface List, so as not to nail yourself to using a particular list class.
- Why is "names" lowercase? Class names should begin with a capital.
- The EMPTY_LIST should probably be unmodifiable unless you explicitly expect callers to add data to that list, which is probably not a good idea anyway
public final static List<names> EMPTY_LIST = Collections.unmodifiableList(new LinkedList<names>());
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...