How to create a search filter for a Three-Dimensional String?

Asked

Viewed 785 times

-1

I have a ArrayList of the kind String Three-dimensional:

String[][]

And I would like to do a search system that filters the values, example:

String[][] table = {{"Ronaldo","32","Atacante","Sao Paulo"},
                    {"Cristiano","25","Meio Campo","Curitiba"},
                    {"Marcos","27","Goleiro","Ponte Preta"};

Well, we assume you have a search page with the fields "Name", "Age", "Field Position" and "Playing Team", the user goes and fills only the fields Age and Position and would like to make a search system that presents all the results that contain the respective parameters, it is possible?

  • You are using JAVA 8?

  • 1

    Three-dimensional string? won’t mean, array of arrays?

  • Well, in the course I was following in videos he said it was three-dimensional string, this wrong?

1 answer

0

Jeiferson, we call that a matrix. A vector of vectors. Three-dimensional would be String[][][].

But, answering your question, it is possible yes. Just go through the matrix in search of what you need. I suggest you use some search method like Binary Search, it will optimize your search.

But I think the correct question would be, "This is the best data structure to do this?"

I don’t know what the origin of this data is, but if it came from a database, consider using some framework ORM. I suggest Hibernate.

  • Okay, I’ll try to do, if you have any doubts I comment here...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.