-1

I have the followig list:

List<String> item = new ArrayList<String>();

It contains a list with fruites. How to filter the list after the first 1 or 2 or three characters from an element (startsWith()) and display the first element from the list after it is filtered?

Can someone please give me an example?

Appreciate!!

just ME
  • 1,817
  • 6
  • 32
  • 53

1 Answers1

0

you can use collection for this

 Collections.sort(item, new Comparator<String>() {
    @Override
    public int compare(String s1, String s2) {
        return s1.compareToIgnoreCase(s2);
    }
});
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78